Issue : Binding Integer Array upon form submission

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue : Binding Integer Array upon form submission

Muhammad Salman Farooq1


We have just migrated our application from 2.2.3 to struts 2.5.20.
In one of our use-cases, we have two checkboxes with same "name" attribute
and upon submission, they submit integer values that we bind with Integer
array being defined in the action.
After migration, that thing stopped working.
Here is my code snippet in JSP:


<input type="checkbox" name="rfaAccessType" value="1"
id="rfaacess_STORAGE">


<input type="checkbox" name="rfaAccessType" value="2" id="rfaacess_SERVER">





Here is the integer array in Action class (Setters and getters also
defined)


private Integer[] rfaAccessType;





I need your help to remediate this issue. If this way of submitting form
and binding it to an array still supported in Struts? If not, what should I
do so that I have minimum change in my code?

Regards,
Muhammad Salman Farooq
Lead Developer - HWSW Server Program
OCAJP | OCPJP Java SE 7
IBM Global Business Services
Islamabad, Pakistan

Phone: 92-0345-5061795 | 92-0304-6664753
E-mail: [hidden email]
Reply | Threaded
Open this post in threaded view
|

RE: Issue : Binding Integer Array upon form submission

Yasser Zamani-2
Hi Muhammad,

I tested your sample exactly and works as expected here (setRfaAccessType(Integer[] rfaAccessType) called with ticked values).

The first thing you can do is enabling devMode and log level to warn and looking output for any relevant warnings. If not try debug level.

Thanks for using Struts.

Regards.

>-----Original Message-----
>From: Muhammad Salman Farooq1 <[hidden email]>
>Sent: Monday, March 18, 2019 2:51 PM
>To: [hidden email]
>Subject: Issue : Binding Integer Array upon form submission
>
>
>
>We have just migrated our application from 2.2.3 to struts 2.5.20.
>In one of our use-cases, we have two checkboxes with same "name" attribute
>and upon submission, they submit integer values that we bind with Integer array
>being defined in the action.
>After migration, that thing stopped working.
>Here is my code snippet in JSP:
>
>
><input type="checkbox" name="rfaAccessType" value="1"
>id="rfaacess_STORAGE">
>
>
><input type="checkbox" name="rfaAccessType" value="2"
>id="rfaacess_SERVER">
>
>
>
>
>
>Here is the integer array in Action class (Setters and getters also
>defined)
>
>
>private Integer[] rfaAccessType;
>
>
>
>
>
>I need your help to remediate this issue. If this way of submitting form and
>binding it to an array still supported in Struts? If not, what should I do so that I
>have minimum change in my code?
>
>Regards,
>Muhammad Salman Farooq
>Lead Developer - HWSW Server Program
>OCAJP | OCPJP Java SE 7
>IBM Global Business Services
>Islamabad, Pakistan
>
>Phone: 92-0345-5061795 | 92-0304-6664753
>E-mail: [hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]