struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sreekanth S. Nair" <sreekanth.n...@egovernments.org>
Subject Re: Getting lists back from struts
Date Wed, 07 Aug 2013 17:51:02 GMT
Check this tutorial might help you
http://www.mkyong.com/struts2/how-to-set-default-value-for-multiple-checkboxes-in-struts-2/

-- 
Thanks & Regards
Srikanth
Software Developer
--------------------------------
eGovernments Foundations
www.egovernments.org
Mob : 9980078913
--------------------------------


On Wed, Aug 7, 2013 at 7:13 PM, Fabian Richter <frichter@mtg.de> wrote:

> Hi
>
> I have encountered this issue a couple of times, always found a way to
> code around but now I really need to ask:
>
> Can struts create lists/arrays (or whatever collection) when e.g. using
>
> public class MyAction extends ActionSupport {
>       public List<Choice> getChoices() {
>          ....
>       }
>       ....
>       public List<String> getPreSelectedChoices() {
>          // returns a list of Choice.getKey(), which is a String
>          ....
>       }
>  }
>
>  public class Choice {
>      public String getKey() { ...}
>      public String getDisplayName() { ... }
>      ....
>  }
>
>  <ww:checkboxlist name="myChoice"
>                               list="%{choices}"
>                               listKey="%{'key'}"
>                               listValue="%{'displayName'}"
>                               value="%{preSelectedChoices}" />
>
> The selected values are sent to
>
> public void setMyChoice(String myChoice){
>         ...
> }
>
> correct? There is no way somthing like
>
> public void setMyChoice(String[] myChoice){
>         ...
> }
>
> works in struts?
>
> If not, whats the common way to get the values back from the String
> myChoice? Use Split on it?
>
> Thank you!
>
> Best
> Fabian
>
>

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