You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kevin Wade <kw...@mindspring.com> on 2008/08/07 13:39:16 UTC

[s2] getting checkbox values in nested iterator tags

This is probably simple and I think I'm close, but I can't quite get  
it to work:  the proper ognl expression to use to get the value of a  
checkbox w/in nested iterator tags.

I've got an ArrayList of Parent objects called parentList.  Each  
Parent object contains another array of Child objects called  
childList.  A Child object has an boolean field called "selected."

If I nest the iterators like so:
<s:iterator value="parentList" status="parentliststatus">
	<s:iterator value="childList" status="childliststatus">

Then what would be the correct expression to use for a checkbox to get  
the value of selected?  I tried the following, but it doesn't seem to  
work:

<s:checkbox name="%{'parentList['+#parentliststatus.index 
+'].childList['+#childliststatus.index+'].selected'}"  
value="selected"></s:checkbox>

That, in turn, produces some html like this:

<input type="checkbox" name="parentList[1].childList[2].selected"  
value="true" checked="checked"  
id="commentsPrint_parentList_1__childList_2__selected"/>
<input type="hidden"  
name="__checkbox_parentList[1].childList[2].selected" value="true" />

But, that doesn't appear to work.  I continue to get setParameter  
errors when I submit the form:
DEBUG com.opensymphony.xwork2.interceptor.ParametersInterceptor -  
Setting params parentList[1].childList[2].selected => [ true ]
ERROR com.opensymphony.xwork2.interceptor.ParametersInterceptor -  
ParametersInterceptor - [setParameters]: Unexpected Exception caught  
setting 'parentList[1].childList[2].selected' on 'class  
com.blackstream.yardly.actions.comments.CommentsPrintAction: Error  
setting expression 'parentList[1].childList[2].selected' with value  
'[Ljava.lang.String;@6d650f'

Any ideas what I'm doing wrong?

Kevin

Re: [s2] getting checkbox values in nested iterator tags

Posted by Kevin Wade <kw...@mindspring.com>.
I re-wrote my ognl expression slightly into this:

parentList[%{#parentliststatus.index}].childList[% 
{#childliststatus.index}].selected

It seems to work now.  Perhaps I had a typo in my original ognl  
statement?  I don't know.  Probably something dumb.  In the immortal  
words of Chris Farley: "stupid! stupid! stupid!"


On Aug 7, 2008, at Thursday, August 7, 2008  - 9:28 AM, Kevin Wade  
wrote:

> S2 2.0.11. The selected field is a boolean.  And there are  
> isSelected() and setSelected() methods.
>
> Thanks for asking.
>
>
> On Aug 7, 2008, at Thursday, August 7, 2008  - 9:24 AM, Gabriel  
> Belingueres wrote:
>
>> Which version of S2 are you using?
>> The selected field: Is it boolean or Boolean?
>> Did you write a getSelected() getter? or is it an isSelected()  
>> getter?
>>
>> 2008/8/7, Kevin Wade <kw...@mindspring.com>:
>>> This is probably simple and I think I'm close, but I can't quite  
>>> get it to
>>> work:  the proper ognl expression to use to get the value of a  
>>> checkbox w/in
>>> nested iterator tags.
>>>
>>> I've got an ArrayList of Parent objects called parentList.  Each  
>>> Parent
>>> object contains another array of Child objects called childList.   
>>> A Child
>>> object has an boolean field called "selected."
>>>
>>> If I nest the iterators like so:
>>> <s:iterator value="parentList" status="parentliststatus">
>>>      <s:iterator value="childList" status="childliststatus">
>>>
>>> Then what would be the correct expression to use for a checkbox to  
>>> get the
>>> value of selected?  I tried the following, but it doesn't seem to  
>>> work:
>>>
>>> <s:checkbox
>>> name="%{'parentList['+#parentliststatus.index 
>>> +'].childList['+#childliststatus.index+'].selected'}"
>>> value="selected"></s:checkbox>
>>>
>>> That, in turn, produces some html like this:
>>>
>>> <input type="checkbox"
>>> name="parentList[1].childList[2].selected" value="true"
>>> checked="checked"
>>> id="commentsPrint_parentList_1__childList_2__selected"/>
>>> <input type="hidden"
>>> name="__checkbox_parentList[1].childList[2].selected"
>>> value="true" />
>>>
>>> But, that doesn't appear to work.  I continue to get setParameter  
>>> errors
>>> when I submit the form:
>>> DEBUG
>>> com.opensymphony.xwork2.interceptor.ParametersInterceptor
>>> - Setting params parentList[1].childList[2].selected => [
>>> true ]
>>> ERROR
>>> com.opensymphony.xwork2.interceptor.ParametersInterceptor
>>> - ParametersInterceptor - [setParameters]: Unexpected Exception  
>>> caught
>>> setting 'parentList[1].childList[2].selected' on 'class
>>> com.blackstream.yardly.actions.comments.CommentsPrintAction:
>>> Error setting expression
>>> 'parentList[1].childList[2].selected' with value
>>> '[Ljava.lang.String;@6d650f'
>>>
>>> Any ideas what I'm doing wrong?
>>>
>>> Kevin
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


Re: [s2] getting checkbox values in nested iterator tags

Posted by Kevin Wade <kw...@mindspring.com>.
S2 2.0.11. The selected field is a boolean.  And there are  
isSelected() and setSelected() methods.

Thanks for asking.


On Aug 7, 2008, at Thursday, August 7, 2008  - 9:24 AM, Gabriel  
Belingueres wrote:

> Which version of S2 are you using?
> The selected field: Is it boolean or Boolean?
> Did you write a getSelected() getter? or is it an isSelected() getter?
>
> 2008/8/7, Kevin Wade <kw...@mindspring.com>:
>> This is probably simple and I think I'm close, but I can't quite  
>> get it to
>> work:  the proper ognl expression to use to get the value of a  
>> checkbox w/in
>> nested iterator tags.
>>
>> I've got an ArrayList of Parent objects called parentList.  Each  
>> Parent
>> object contains another array of Child objects called childList.  A  
>> Child
>> object has an boolean field called "selected."
>>
>> If I nest the iterators like so:
>> <s:iterator value="parentList" status="parentliststatus">
>>       <s:iterator value="childList" status="childliststatus">
>>
>> Then what would be the correct expression to use for a checkbox to  
>> get the
>> value of selected?  I tried the following, but it doesn't seem to  
>> work:
>>
>> <s:checkbox
>> name="%{'parentList['+#parentliststatus.index 
>> +'].childList['+#childliststatus.index+'].selected'}"
>> value="selected"></s:checkbox>
>>
>> That, in turn, produces some html like this:
>>
>> <input type="checkbox"
>> name="parentList[1].childList[2].selected" value="true"
>> checked="checked"
>> id="commentsPrint_parentList_1__childList_2__selected"/>
>> <input type="hidden"
>> name="__checkbox_parentList[1].childList[2].selected"
>> value="true" />
>>
>> But, that doesn't appear to work.  I continue to get setParameter  
>> errors
>> when I submit the form:
>> DEBUG
>> com.opensymphony.xwork2.interceptor.ParametersInterceptor
>> - Setting params parentList[1].childList[2].selected => [
>> true ]
>> ERROR
>> com.opensymphony.xwork2.interceptor.ParametersInterceptor
>> - ParametersInterceptor - [setParameters]: Unexpected Exception  
>> caught
>> setting 'parentList[1].childList[2].selected' on 'class
>> com.blackstream.yardly.actions.comments.CommentsPrintAction:
>> Error setting expression
>> 'parentList[1].childList[2].selected' with value
>> '[Ljava.lang.String;@6d650f'
>>
>> Any ideas what I'm doing wrong?
>>
>> Kevin
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>


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


Re: [s2] getting checkbox values in nested iterator tags

Posted by Gabriel Belingueres <be...@gmail.com>.
Which version of S2 are you using?
The selected field: Is it boolean or Boolean?
Did you write a getSelected() getter? or is it an isSelected() getter?

2008/8/7, Kevin Wade <kw...@mindspring.com>:
> This is probably simple and I think I'm close, but I can't quite get it to
> work:  the proper ognl expression to use to get the value of a checkbox w/in
> nested iterator tags.
>
> I've got an ArrayList of Parent objects called parentList.  Each Parent
> object contains another array of Child objects called childList.  A Child
> object has an boolean field called "selected."
>
> If I nest the iterators like so:
> <s:iterator value="parentList" status="parentliststatus">
>        <s:iterator value="childList" status="childliststatus">
>
> Then what would be the correct expression to use for a checkbox to get the
> value of selected?  I tried the following, but it doesn't seem to work:
>
> <s:checkbox
> name="%{'parentList['+#parentliststatus.index+'].childList['+#childliststatus.index+'].selected'}"
> value="selected"></s:checkbox>
>
> That, in turn, produces some html like this:
>
> <input type="checkbox"
> name="parentList[1].childList[2].selected" value="true"
> checked="checked"
> id="commentsPrint_parentList_1__childList_2__selected"/>
> <input type="hidden"
> name="__checkbox_parentList[1].childList[2].selected"
> value="true" />
>
> But, that doesn't appear to work.  I continue to get setParameter errors
> when I submit the form:
> DEBUG
> com.opensymphony.xwork2.interceptor.ParametersInterceptor
> - Setting params parentList[1].childList[2].selected => [
> true ]
> ERROR
> com.opensymphony.xwork2.interceptor.ParametersInterceptor
> - ParametersInterceptor - [setParameters]: Unexpected Exception caught
> setting 'parentList[1].childList[2].selected' on 'class
> com.blackstream.yardly.actions.comments.CommentsPrintAction:
> Error setting expression
> 'parentList[1].childList[2].selected' with value
> '[Ljava.lang.String;@6d650f'
>
> Any ideas what I'm doing wrong?
>
> Kevin

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