You can't nest struts tags so you can't put a <s:text>  inside of <s:radio>
tag but you should be able to call getText().
I would try this:

<s:radio key="My choice" list="#{true:getText('yes'), false:getText('no')}"
value="true" />


On Wed, Nov 4, 2009 at 10:44 AM, Qunhuan Mei <q...@qm18.wanadoo.co.uk> wrote:

> Hi,
>
>
>
> For a single pair of radio buttons, e.g. "Yes" or "No" without
> localisation,
> the following jsp code seems to be straight forward and will always come
> out
> with true/false returned to the server (localised Yes or No can be received
> on the server after user have made choice, but this is not the optimal
> solution I want. I want always true/false or 1/0):
>
>
>
> <s:radio key="My choice" list="#{true:'Yes', false:'No'}" value="true" />
>
>
>
>
>
> But:
>
>
>
> 1.         I wan to localise the Yes and No with still true/false to come
> out, I failed. I have tried:
>
>
>
> list="#{true:'<s:text name="yes"/>', false:'<s:text name="no"/>'}"
>
>
>
> or
>
>
>
> list="#{true:'${yes}', false:'${no}'}"
>
> list="#{true:%{#yes}, false:%{#no} }}"            etc
>
>
>
> hoping to access the following getter in the action class:
>
>
>
>            public String getYes(){
>
>                        return getText("yes");
>
>            }
>
>            public String getNo(){
>
>                        return getText("no");
>
>            }
>
>
>
> (Can a Struts tag embedded in another Struts tag?)
>
>
>
> 2.         I also failed to set the list value from action class for the
> given jsp code. This is what I have tried:
>
>
>
> Jsp code:
>
>
>
> <s:radio key="My choice" list="yesOrNoList" value="true" />
>
>
>
> a.         getter method returns a (array) list:
>
>
>
> public List<String> getYesOrNoList() {
>
>                                    String[] yesOrNoArray = {getText("yes"),
> getText("no")};
>
>            return Arrays.asList(yesOrNoArray);
>
> }
>
>
>
> b.         getter method returns a (map) list:
>
>
>
> public List<Map> getYesOrNoList() {
>
> Map[] yesOrNoArray = {new HashMap(), new HashMap()};
>
>            yesOrNoArray[0].put(true, getText("yes"));
>
>            yesOrNoArray[1].put(false, getText("no"));
>
>   return Arrays.asList(translateYesOrNoArray);
>
> }
>
>
>
> c.         getter method returns a collection:
>
>
>
> public Collection<Map> getYesOrNoList() {
>
>            Map yesOrNoArray = new HashMap();//, new HashMap()};
>
> yesOrNoArray.put(true, getText("yes"));
>
>            yesOrNoArray.put(false, getText("no"));
>
>            return yesOrNoArray.values();
>
> }
>
>
>
>
>
> None of them produced the ideal result for me.
>
>
>
> Could any one help please? Much appreciated.
>
>
>
> Qunhuan
>
>

Reply via email to