You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by M Huzaifah <mh...@gmail.com> on 2018/12/21 08:14:21 UTC

[ask] How to pass multiple radio button in struts2

Hi Members,

i would like to ask something about radio button in strtus2.

i have radio button in jsp like this:


<fieldset id="fieldSetView0">
   <input type="radio" name="viewAccess[0]" value="all"> All<br>
   <input type="radio" name="viewAccess[0]" value="self"> Self<br>
   <input type="radio" name="viewAccess[0]" value="custom"> Custom
</fieldset>

<fieldset id="fieldSetView1">
   <input type="radio" name="viewAccess[1]" value="all"> All<br>
   <input type="radio" name="viewAccess[1]" value="self"> Self<br>
   <input type="radio" name="viewAccess[1]" value="custom"> Custom
</fieldset>

and in my JavaAction class i add property " private String viewAccess[]; “ also with setter and getter.

the problem is, i am not able to get value of radio button in Java Action. i use struts 2.3.35

someone could help?

Thank you


Re: [ask] How to pass multiple radio button in struts2

Posted by M Huzaifah <mh...@gmail.com>.
Hi Yasser,

i tried, it will exception.

 i use this code bellow to get that value, instead for loop:
request.getParameterValues("viewAccess["+i+"]")[0]
this work for me. i’ll update if i got the proper way about this

Thank you


> On 22 Dec 2018, at 15.31, Yasser Zamani <ya...@apache.org> wrote:
> 
> Hi,
> 
> As different values are setting into same viewAccess[0], I guess instead `private String viewAccess[][];` (array of array) would work.
> 
> Regards. 
> 
>> -----Original Message-----
>> From: M Huzaifah <mh...@gmail.com>
>> Sent: Friday, December 21, 2018 11:44 AM
>> To: Struts Users Mailing List <us...@struts.apache.org>
>> Subject: [ask] How to pass multiple radio button in struts2
>> 
>> Hi Members,
>> 
>> i would like to ask something about radio button in strtus2.
>> 
>> i have radio button in jsp like this:
>> 
>> 
>> <fieldset id="fieldSetView0">
>>  <input type="radio" name="viewAccess[0]" value="all"> All<br>
>>  <input type="radio" name="viewAccess[0]" value="self"> Self<br>
>>  <input type="radio" name="viewAccess[0]" value="custom"> Custom
>> </fieldset>
>> 
>> <fieldset id="fieldSetView1">
>>  <input type="radio" name="viewAccess[1]" value="all"> All<br>
>>  <input type="radio" name="viewAccess[1]" value="self"> Self<br>
>>  <input type="radio" name="viewAccess[1]" value="custom"> Custom
>> </fieldset>
>> 
>> and in my JavaAction class i add property " private String viewAccess[]; “ also with
>> setter and getter.
>> 
>> the problem is, i am not able to get value of radio button in Java Action. i use
>> struts 2.3.35
>> 
>> someone could help?
>> 
>> Thank you
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org


RE: [ask] How to pass multiple radio button in struts2

Posted by Yasser Zamani <ya...@apache.org>.
Hi,

As different values are setting into same viewAccess[0], I guess instead `private String viewAccess[][];` (array of array) would work.

Regards. 

>-----Original Message-----
>From: M Huzaifah <mh...@gmail.com>
>Sent: Friday, December 21, 2018 11:44 AM
>To: Struts Users Mailing List <us...@struts.apache.org>
>Subject: [ask] How to pass multiple radio button in struts2
>
>Hi Members,
>
>i would like to ask something about radio button in strtus2.
>
>i have radio button in jsp like this:
>
>
><fieldset id="fieldSetView0">
>   <input type="radio" name="viewAccess[0]" value="all"> All<br>
>   <input type="radio" name="viewAccess[0]" value="self"> Self<br>
>   <input type="radio" name="viewAccess[0]" value="custom"> Custom
></fieldset>
>
><fieldset id="fieldSetView1">
>   <input type="radio" name="viewAccess[1]" value="all"> All<br>
>   <input type="radio" name="viewAccess[1]" value="self"> Self<br>
>   <input type="radio" name="viewAccess[1]" value="custom"> Custom
></fieldset>
>
>and in my JavaAction class i add property " private String viewAccess[]; “ also with
>setter and getter.
>
>the problem is, i am not able to get value of radio button in Java Action. i use
>struts 2.3.35
>
>someone could help?
>
>Thank you