« Return to Thread: problem

Re: <s:select> problem

by Laurie Harper :: Rate this Message:

Reply to Author | View in Thread

Arpan Debroy wrote:
> I have a JPA query like that
>
> Query query = em.createQuery("*SELECT c.name, c.id FROM Group c ORDER BY
> c.name*");
>         List resultList = query.getResultList();

Have you verified that the query is returning a non-empty list -- i.e.
resultList really contains data to display? What does the result object
  JPA produces for an ad-hoc query like that look like? I don't recall
off the top of my head, but I suspect it's something like
List<Map<String, Object>> or possibly List<Map<String, String>>?

> In Action class I have *resultList *and *GroupId *declared with getter and
> setters
>
> private List resultList ;
> private long GroupId;
>
> In JSP I have written like that :
>
> *<s:select name="GroupId" list="resultList"  listKey="id" listValue="name"
> value="%{GroupId}" />*

That should be 'groupId' not 'GroupId'; case is important, and the
convention is specified by the JavaBeans spec.

> But nothing is displaying in my drop down box when I put listkey and
> listvalue.

According to your previous reply on this thread, the options are
rendered correctly but none is selected. Is that right? That would be
explained by the mis-spelled 'GroupId'. If that doesn't fix it, make
sure the type of the groupId property matches the type of the 'id'
property in the JPA result object.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@...
For additional commands, e-mail: user-help@...

 « Return to Thread: problem