struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From " Qunhuan Mei">
Subject Radio button issue with list, map, collection, localisation and action class.
Date Wed, 04 Nov 2009 15:44:49 GMT


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" />





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"/>'}"




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"),

            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. 



  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message