Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing variable number of parameters from form in to action in struts 2
    primarykey
    data
    text
    <p>I am using struts2 in my application and have a form in a jsp which is submitted to a action class.</p> <p>The number of input fields in the form can vary at runtime and hence the action class can not have fixed setter and getter for the parameters. I am trying to capture these variable number of inputs in a single action class. I want to know if its possible via Struts 2 and if it is how can i do it ? I am aware of the input field names in the form (input field names populated via iterator in the jsp form).</p> <p>Note: 1) I am aware of the way to capture the form values (parameters) in the action class via the appropriate getter and setter for all form values in the action class. 2) I have gone through the model driven action as described in struts 2 <a href="http://struts.apache.org/2.3.1/docs/model-driven.html" rel="nofollow">http://struts.apache.org/2.3.1/docs/model-driven.html</a></p> <p>I could not get any solution on searching and any help is appreciated.</p> <p>Form population code:</p> <pre><code>&lt;s:form action="/reports/getReport.action" cssClass="table_with_padding"&gt; &lt;s:iterator value="reportParamsList.items" id="paramList_item"&gt; &lt;tr&gt;&lt;td&gt;&lt;s:property value="#paramList_item.paramdesc" /&gt;&lt;/td&gt;&lt;TD&gt;&lt;s:textfield name="#paramList_item.paramname" /&gt;&lt;/TD&gt;&lt;/tr&gt; &lt;/s:iterator&gt; &lt;s:submit theme="ajax" loadingText="%{getResource('SiteWide.Loading.Text')}" targets="app_area" type="button" align="left" cssClass="app_form_button" value="Submit" /&gt; &lt;/s:form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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