|
View:
New views
20 Messages
—
Rating Filter:
Alert me
|
|
|
NoResult - write response in the ActionI have a situation where I want to fully handle the result in the Action
including writing the response to the HttpServletResponse. What's the best way to handle this so there is no further results processing after the execute() method ends? Is there a way to disable results processing from within the action's execute() method? Or, should I write a "NoResult" Result that does nothing? I know I could write a custom Result and move all the logic from the action to the custom result but it would be a PITA and make this situation much more complex then it needs to be. I would have to split the logic in the action in an artificial way and expose a bunch of internal variables just so they could be passed to the Result and then I would have to duplicate logic that is already available in the action super classes, etc in the result. |
|
|
Re: NoResult - write response in the ActionOn Today at 5:13pm, GL=>Greg Lindholm <greg.lindholm@...> wrote:
GL> I have a situation where I want to fully handle the result in the Action GL> including writing the response to the HttpServletResponse. GL> return ActionSupport.NONE? GL> GL> What's the best way to handle this so there is no further results processing GL> after the execute() method ends? GL> GL> Is there a way to disable results processing from within the action's GL> execute() method? GL> Or, should I write a "NoResult" Result that does nothing? GL> GL> I know I could write a custom Result and move all the logic from the action GL> to the custom result but it would be a PITA and make this situation much GL> more complex then it needs to be. I would have to split the logic in the GL> action in an artificial way and expose a bunch of internal variables just so GL> they could be passed to the Result and then I would have to duplicate logic GL> that is already available in the action super classes, etc in the result. GL> -- Haroon Rafique <haroon.rafique@...> --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Doubleselect tag doubleEmptyOptionDear all,
Did anyone used the doubleEmptyOption parameter of the doubleselect tag in struts2? I have used it to create an empty option for the second select box. However no empty option is added. In addition, the doubleHeaderKey and doubleHeaderValue parameters are also seems has no effect at all. I checked the doubleselect.vm file, and I haven't found anything regarding the above three parameters. So are these not implemented? Or I just configured wrong. I am using Struts 2.1.8. Many thanks for any reply in advance, Nathan --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: NoResult - write response in the ActionThanks that did the trick.
Where did you learn about the NONE result? Is it documented somewhere? On Tue, Nov 3, 2009 at 5:56 PM, Haroon Rafique <haroon.rafique@...>wrote: > On Today at 5:13pm, GL=>Greg Lindholm <greg.lindholm@...> wrote: > > GL> I have a situation where I want to fully handle the result in the > Action > GL> including writing the response to the HttpServletResponse. > GL> > > > return ActionSupport.NONE? > > > GL> > GL> What's the best way to handle this so there is no further results > processing > GL> after the execute() method ends? > GL> > GL> Is there a way to disable results processing from within the action's > GL> execute() method? > GL> Or, should I write a "NoResult" Result that does nothing? > GL> > GL> I know I could write a custom Result and move all the logic from the > action > GL> to the custom result but it would be a PITA and make this situation > much > GL> more complex then it needs to be. I would have to split the logic in > the > GL> action in an artificial way and expose a bunch of internal variables > just so > GL> they could be passed to the Result and then I would have to duplicate > logic > GL> that is already available in the action super classes, etc in the > result. > GL> > > -- > Haroon Rafique > <haroon.rafique@...> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > |
|
|
Re: NoResult - write response in the ActionYes. See:
http://www.opensymphony.com/xwork/api/com/opensymphony/xwork/ActionSupport.html http://www.opensymphony.com/xwork/api/com/opensymphony/xwork/Action.html#NONE -Brian On Wed, Nov 4, 2009 at 8:42 AM, Greg Lindholm <greg.lindholm@...>wrote: > Thanks that did the trick. > > Where did you learn about the NONE result? Is it documented somewhere? > > On Tue, Nov 3, 2009 at 5:56 PM, Haroon Rafique > <haroon.rafique@...>wrote: > > > On Today at 5:13pm, GL=>Greg Lindholm <greg.lindholm@...> wrote: > > > > GL> I have a situation where I want to fully handle the result in the > > Action > > GL> including writing the response to the HttpServletResponse. > > GL> > > > > > > return ActionSupport.NONE? > > > > > > GL> > > GL> What's the best way to handle this so there is no further results > > processing > > GL> after the execute() method ends? > > GL> > > GL> Is there a way to disable results processing from within the action's > > GL> execute() method? > > GL> Or, should I write a "NoResult" Result that does nothing? > > GL> > > GL> I know I could write a custom Result and move all the logic from the > > action > > GL> to the custom result but it would be a PITA and make this situation > > much > > GL> more complex then it needs to be. I would have to split the logic in > > the > > GL> action in an artificial way and expose a bunch of internal variables > > just so > > GL> they could be passed to the Result and then I would have to duplicate > > logic > > GL> that is already available in the action super classes, etc in the > > result. > > GL> > > > > -- > > Haroon Rafique > > <haroon.rafique@...> > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: user-unsubscribe@... > > For additional commands, e-mail: user-help@... > > > > > |
|
|
Re: NoResult - write response in the ActionOn Today at 9:42am, GL=>Greg Lindholm <greg.lindholm@...> wrote:
GL> Thanks that did the trick. GL> GL> Where did you learn about the NONE result? Is it documented somewhere? GL> Hi Greg, I first saw it in the 2.0.11 source code when trying to create a new result type. The javadoc for it was quite helpful: * The action execution was successful but do not show a view. This is useful for actions that are handling the view in another fashion like redirect. There is a reference to it in the "Result Configuration" documentation as well: http://struts.apache.org/2.1.8/docs/result-configuration.html Later, -- Haroon Rafique <haroon.rafique@...> --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: NoResult - write response in the ActionThanks. I did see the javadoc for NONE (after you suggested using it). It
just seemed to me to be a little vague considering that NONE really is a special case as it is the only result that is 'functional' where the others are more like 'convention'. In any case it certainly wasn't a place I thought to look. I think I will add a note to the "Result Configuration" documentation. On Wed, Nov 4, 2009 at 10:05 AM, Haroon Rafique <haroon.rafique@...>wrote: > On Today at 9:42am, GL=>Greg Lindholm <greg.lindholm@...> wrote: > > GL> Thanks that did the trick. > GL> > GL> Where did you learn about the NONE result? Is it documented somewhere? > GL> > > Hi Greg, > > I first saw it in the 2.0.11 source code when trying to create a new > result type. The javadoc for it was quite helpful: > > * The action execution was successful but do not show a view. This is > useful for actions that are handling the view in another fashion > like redirect. > > There is a reference to it in the "Result Configuration" documentation as > well: > http://struts.apache.org/2.1.8/docs/result-configuration.html > > Later, > -- > Haroon Rafique > <haroon.rafique@...> > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > |
|
|
Re: NoResult - write response in the ActionHey Admins... I don't seem to be able to edit
http://struts.apache.org/2.x/docs/result-configuration.html is there a problem with the wiki (or is it just down for maintenance)? On Wed, Nov 4, 2009 at 10:24 AM, Greg Lindholm <greg.lindholm@...>wrote: > Thanks. I did see the javadoc for NONE (after you suggested using it). It > just seemed to me to be a little vague considering that NONE really is a > special case as it is the only result that is 'functional' where the others > are more like 'convention'. In any case it certainly wasn't a place I > thought to look. > > I think I will add a note to the "Result Configuration" documentation. > > |
|
|
Radio button issue with list, map, collection, localisation and action class.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 |
|
|
Re: Radio button issue with list, map, collection, localisation and action class.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 <qm@...> 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 > > |
|
|
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.lindholm@...> > 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 <qm@...> > 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 > > > > > |
|
|
RE: Radio button issue with list, map, collection, localisation and action class.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.job@...] 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.lindholm@...> > 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 <qm@...> > 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 > > 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-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: Radio button issue with list, map, collection, localisation and action class.At least with String keys, it works fine:
Code in your action: private Map<String, String> myMap = new LinkedHashMap<String, String>(); .. myMap .put("key1", "Yes");// or getText(..) myMap .put("key2", "No"); .. public Map<String, String> getMyMap() { return myMap; } JSP: <s:radio list="myMap" name=".." /> 2009/11/4 Qunhuan Mei <qm@...> > 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.job@...] > 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.lindholm@...> > > > 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 <qm@...> > > 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-unsubscribe@... > For additional commands, e-mail: user-help@... > > |
|
|
RE: Radio button issue with list, map, collection, localisation and action class.My understanding was wrong - thought it has to be "List". Also did not think
about LinkedHashMap. Tried also <Integer, String> and working fine. Guess <Boolean, String> should also work. Cheers! -----Original Message----- From: Samuel Robert [mailto:samuelrobert.job@...] Sent: 04 November 2009 16:52 To: Struts Users Mailing List Subject: Re: Radio button issue with list, map, collection, localisation and action class. At least with String keys, it works fine: Code in your action: private Map<String, String> myMap = new LinkedHashMap<String, String>(); .. myMap .put("key1", "Yes");// or getText(..) myMap .put("key2", "No"); .. public Map<String, String> getMyMap() { return myMap; } JSP: <s:radio list="myMap" name=".." /> 2009/11/4 Qunhuan Mei <qm@...> > 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.job@...] > 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.lindholm@...> > > > 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 <qm@...> > > 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-unsubscribe@... > For additional commands, e-mail: user-help@... > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: NoResult - write response in the ActionI believe I have places where I return "null" (the value, not the string) to achieve this same purpose... ...from this discussion it sounds like I should be returning ActionSupport.NONE (which I assumed would have the value null, but actually has the value "none")...can anyone comment on which of these return values is more appropriate, or if the "correct" answer changed at some point and I missed the changelog? I know--I'm being a bit lazy by not digging through the source to find out, but lunch (and errands) are calling me :-) -Dale |
|
|
Re: NoResult - write response in the ActionLooking at the code it appears that (null) and "none" are treated the same
and both cause results processing to be skipped. Look for createResult() and executeResult() in DefaultActionInvocation: http://svn.opensymphony.com/fisheye/browse/~raw,r=1851/xwork/trunk/src/java/com/opensymphony/xwork2/DefaultActionInvocation.java On Thu, Nov 5, 2009 at 11:49 AM, DNewfield <Dale@...> wrote: > > > Haroon Rafique wrote: > > > > On Today at 5:13pm, GL=>Greg Lindholm <greg.lindholm@...> wrote: > > GL> I have a situation where I want to fully handle the result in the > > Action > > GL> including writing the response to the HttpServletResponse. > > > > return ActionSupport.NONE? > > > > I believe I have places where I return "null" (the value, not the string) > to > achieve this same purpose... > ...from this discussion it sounds like I should be returning > ActionSupport.NONE (which I assumed would have the value null, but actually > has the value "none")...can anyone comment on which of these return values > is more appropriate, or if the "correct" answer changed at some point and I > missed the changelog? I know--I'm being a bit lazy by not digging through > the source to find out, but lunch (and errands) are calling me :-) > > -Dale > -- > View this message in context: > http://old.nabble.com/NoResult---write-response-in-the-Action-tp26187583p26215803.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > |
|
|
Re: NoResult - write response in the ActionGreg Lindholm wrote:
> Looking at the code it appears that (null) and "none" are treated the same > and both cause results processing to be skipped. Thanks! and the annotated view: http://svn.opensymphony.com/fisheye/browse/xwork/trunk/src/java/com/opensymphony/xwork2/DefaultActionInvocation.java?r=1851 shows that it's been that way for a long time. -Dale --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: NoResult - write response in the ActionWhat will be the view in this case ?
I mean there must be some jsp kinda thing , where the Response can be displayed !! If the framework doesn't goes to the strust.xml file , Can we define some view in the action itself ?? I am curious , may be i am out of context for this.but !! I donno.
|
|
|
Re: NoResult - write response in the ActionIf I understand correctly, the response will just be sent directly to the
client without going through jsp processing. -Brian On Thu, Nov 5, 2009 at 1:36 PM, Siddiq Syed <siddiq_sa@...> wrote: > > What will be the view in this case ? > > I mean there must be some jsp kinda thing , where the Response can be > displayed !! > > If the framework doesn't goes to the strust.xml file , Can we define some > view in the action itself ?? > > I am curious , may be i am out of context for this.but !! I donno. > > > > Greg Lindholm-2 wrote: > > > > Thanks. I did see the javadoc for NONE (after you suggested using it). It > > just seemed to me to be a little vague considering that NONE really is a > > special case as it is the only result that is 'functional' where the > > others > > are more like 'convention'. In any case it certainly wasn't a place I > > thought to look. > > > > I think I will add a note to the "Result Configuration" documentation. > > > > On Wed, Nov 4, 2009 at 10:05 AM, Haroon Rafique > > <haroon.rafique@...>wrote: > > > >> On Today at 9:42am, GL=>Greg Lindholm <greg.lindholm@...> wrote: > >> > >> GL> Thanks that did the trick. > >> GL> > >> GL> Where did you learn about the NONE result? Is it documented > >> somewhere? > >> GL> > >> > >> Hi Greg, > >> > >> I first saw it in the 2.0.11 source code when trying to create a new > >> result type. The javadoc for it was quite helpful: > >> > >> * The action execution was successful but do not show a view. This is > >> useful for actions that are handling the view in another fashion > >> like redirect. > >> > >> There is a reference to it in the "Result Configuration" documentation > as > >> well: > >> http://struts.apache.org/2.1.8/docs/result-configuration.html > >> > >> Later, > >> -- > >> Haroon Rafique > >> <haroon.rafique@...> > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: user-unsubscribe@... > >> For additional commands, e-mail: user-help@... > >> > >> > > > > > > -- > View this message in context: > http://old.nabble.com/NoResult---write-response-in-the-Action-tp26187583p26219072.html > Sent from the Struts - User mailing list archive at Nabble.com. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > |
|
|
Re: NoResult - write response in the ActionSiddiq Syed wrote:
> What will be the view in this case ? This is a special return value reserved primarily for actions that generate their own output directly, and used to indicate that the framework should not dispatch to any view (as the view has already been sent to the requester). -Dale --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
| Free embeddable forum powered by Nabble | Forum Help |