You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by boraldo <bo...@hotbox.ru> on 2009/03/11 15:05:39 UTC

s:radio and s:checkboxlist - how to customize listValue property.

When I use that 2 components in my form I need to set attributes listValue
and listKey.
That attributes as I understand require a field of a bean that is a member
of collection represented by list attribute.

Example:

    <s:radio list="types" name="type" label="Type" listValue="name" 
listKey="id" />

That means: 
1) there will be one radiobutton for each element of collection getTypes().
2) Each html radiobutton will have value = getId()  and label = getName() .

I want to compose label from several fields of my bean. So I can't write

    <s:radio listValue="someField" />

because that class doesn't have getSomeField() method.

How can I do this ?
-- 
View this message in context: http://www.nabble.com/s%3Aradio-and-s%3Acheckboxlist---how-to-customize-listValue-property.-tp22455829p22455829.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: s:radio and s:checkboxlist - how to customize listValue property.

Posted by boraldo <bo...@hotbox.ru>.
>> It isn't ideal if you want to keep your model carefully isolated from your
UI 
Unfortunately it is the case, so I need another solution.


Jim Kiley wrote:
> 
> The easiest (I'm not going to say "best") solution is to make a "fake"
> getter on your bean.  Make a "getListLabel()" method that composes a
> String
> from the values that you want to display in the list label, and then set
> the
> listValue to be "listLabel".  This is the way I've done this in the past
> and
> it works OK.  It isn't ideal if you want to keep your model carefully
> isolated from your UI but my own designs are a little less pure than that.
> jk
> 
> On Wed, Mar 11, 2009 at 10:05 AM, boraldo <bo...@hotbox.ru> wrote:
> 
>>
>> When I use that 2 components in my form I need to set attributes
>> listValue
>> and listKey.
>> That attributes as I understand require a field of a bean that is a
>> member
>> of collection represented by list attribute.
>>
>> Example:
>>
>>    <s:radio list="types" name="type" label="Type" listValue="name"
>> listKey="id" />
>>
>> That means:
>> 1) there will be one radiobutton for each element of collection
>> getTypes().
>> 2) Each html radiobutton will have value = getId()  and label = getName()
>> .
>>
>> I want to compose label from several fields of my bean. So I can't write
>>
>>    <s:radio listValue="someField" />
>>
>> because that class doesn't have getSomeField() method.
>>
>> How can I do this ?
>> --
>> View this message in context:
>> http://www.nabble.com/s%3Aradio-and-s%3Acheckboxlist---how-to-customize-listValue-property.-tp22455829p22455829.html
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 
> -- 
> Jim Kiley
> Senior Technical Consultant | Summa
> [p] 412.258.3346
> http://www.summa-tech.com
> 
> 

-- 
View this message in context: http://www.nabble.com/s%3Aradio-and-s%3Acheckboxlist---how-to-customize-listValue-property.-tp22455829p22458070.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: s:radio and s:checkboxlist - how to customize listValue property.

Posted by Jim Kiley <jh...@summa-tech.com>.
The easiest (I'm not going to say "best") solution is to make a "fake"
getter on your bean.  Make a "getListLabel()" method that composes a String
from the values that you want to display in the list label, and then set the
listValue to be "listLabel".  This is the way I've done this in the past and
it works OK.  It isn't ideal if you want to keep your model carefully
isolated from your UI but my own designs are a little less pure than that.
jk

On Wed, Mar 11, 2009 at 10:05 AM, boraldo <bo...@hotbox.ru> wrote:

>
> When I use that 2 components in my form I need to set attributes listValue
> and listKey.
> That attributes as I understand require a field of a bean that is a member
> of collection represented by list attribute.
>
> Example:
>
>    <s:radio list="types" name="type" label="Type" listValue="name"
> listKey="id" />
>
> That means:
> 1) there will be one radiobutton for each element of collection getTypes().
> 2) Each html radiobutton will have value = getId()  and label = getName() .
>
> I want to compose label from several fields of my bean. So I can't write
>
>    <s:radio listValue="someField" />
>
> because that class doesn't have getSomeField() method.
>
> How can I do this ?
> --
> View this message in context:
> http://www.nabble.com/s%3Aradio-and-s%3Acheckboxlist---how-to-customize-listValue-property.-tp22455829p22455829.html
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Jim Kiley
Senior Technical Consultant | Summa
[p] 412.258.3346
http://www.summa-tech.com