Greg and Samuel, Thank you very much indeed for your quick response. Your suggestions are indeed working!
Just out from my curiosity, would it be possible to achieve the same effect by the code from the action class (I have got no more clue since all my effort failed)? The documentation (2.1.8, radio) said "If the list is a Map (key, value), the Map key will become the option 'value' parameter and the Map value will become the option body." But when I tried my "map" list, the "key=value" were shown together rather than value were shown and the key were sent to the server after choice is made. Cheers, Q -----Original Message----- From: Samuel Robert [mailto:samuelrobert....@gmail.com] Sent: 04 November 2009 16:07 To: Struts Users Mailing List Subject: Re: Radio button issue with list, map, collection, localisation and action class. This should also work: <s:text var="yes" name="yes"/> <s:text var="no" name="no"/> <s:radio key="My choice" list="#{true:#yes, false:#no}" value="true" /> 2009/11/4 Greg Lindholm <greg.lindh...@gmail.com> > 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 > > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@struts.apache.org For additional commands, e-mail: user-h...@struts.apache.org