Note that there are some explanatory texts on larger screens.

plurals
  1. POStruts2 checkboxes returning values in Action class
    primarykey
    data
    text
    <p>Im pretty new to struts2, so Im trying to post everything you need to understand my problem,Your help is much appreciated. try to be more clear, i'm in lack of ideas in this problem, even it sounds like a classic .</p> <pre><code>&lt;s:checkbox name="selectedIndex" theme="simple" &gt; &lt;/s:checkbox&gt; </code></pre> <p>I have dynamic number of checkboxes in my JSP.Lets say i have three checkbox in my jsp.Then if user select first and second checkbox then i want a array in action class whose element is {1,2}.If user select first and third checkbox then i want a array in action class whose element is {1,3}.How can i do it in struts2?</p> <p>i have getter and setter in action class as:</p> <pre><code>public String[] getSelectedIndex() { return selectedIndex; } public void setSelectedIndex(String[] selectedIndex) { this.selectedIndex = selectedIndex; } </code></pre> <p>so actionClass give me true and false.</p> <p>In the followin code List1(Stored in session object) is list of StatusDTOs and getter,setter are following element of StatusDTO is :-</p> <pre><code>public boolean getIsDisabled() { return this.isDisabled; } public void setIsDisabled(boolean isDisabled) { this.isDisabled=isDisabled; } public int getSerialNo() { return this.serialNo; } public void setSerialNo(int serialNo) { this.serialNo=serialNo; } </code></pre> <p>Actual code in jsp is</p> <pre><code>&lt;% ArrayList temp=(ArrayList)ActionContext.getContext().getSession().get("List1"); Iterator itr=temp.iterator(); while(itr.hasNext()) { StatusDTO psd=(StatusDTO)itr.next(); System.out.println("********"+psd.getSerialNo()); %&gt; &lt;tr&gt; &lt;td bgcolor="#E6FAFB"&gt; &lt;%=psd.getSerialNo()%&gt; &lt;/td&gt; &lt;td bgcolor="#E6FAFB"&gt; &lt;% if(psd.getIsDisabled()) { %&gt; &lt;s:checkbox name="selectedIndex" theme="simple" disabled="true"&gt; &lt;/s:checkbox&gt; &lt;% } else { %&gt; &lt;s:checkbox name="selectedIndex" theme="simple" value="1"&gt; &lt;/s:checkbox&gt; &lt;%} %&gt; &lt;/td&gt; &lt;/tr&gt; &lt;% } %&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload