Hi Laurie,

My JPA query is like that

Query query = em.createQuery("*SELECT c.name, c.id FROM Group c ORDER BY
c.name*");
        List<Group> resultList = query.getResultList();

My "resultList" have all the values.It has the list of rows of id(numerical)
and name(string). "Group" entity has "id" of long type
and "name" of String type.

In Action class I have *resultList *and *groupId *declared with getter and
setters

*private List<Group> resultList ;
private long groupId;*

In JSP I have written like that :

1) If I write like this :-
*<s:select name="groupId" list="resultList"  listKey="id" value="%{groupId}"
/>

*"resultlist" is being displayed in drop down box. But the value not getting
selected according to the "groupId" value.
*And if I submit this, it throws error that invalid field value for the
field "groupId".*

2) If I write like this :-
*<s:select name="groupId" list="resultList"  listKey="id"
listValue="name"value="%{groupId}" />

Nothing is being displayed!!...*

Do I need to write setters and getters for "id" and "name" fields in Action
class.
I did that too.But nothing effects.

How you would like to do that?


On Thu, May 8, 2008 at 9:24 PM, Laurie Harper <[EMAIL PROTECTED]> wrote:

> 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: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


-- 
Thanks & Regards
Arpan Debroy

AOL Online India Private Ltd
RMZ EcoSpace Campus 1A
Outer Ring Road, Bellandur,
Bangalore - 560037
India
Mobile No :+9886006306
on-board :+91 (80) 4035 4528
E-mail : [EMAIL PROTECTED]

Reply via email to