Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


getting  arraylist/array  values in action class

Posted on 2006-05-18
Medium Priority
Last Modified: 2007-12-19
Dear experts

I am using Dynavalidatorform. and in  my jsp i have a field
 <html:select property="abbtlFacs" styleClass="formstyle" tabindex="18" multiple="multiple" size="8" style="width:300px">

the above field has single/multiple values. Now in the action class i am trying to get
the values of the above field like this

DynaValidatorForm f = (DynaValidatorForm) form;
String abbtlFacs = (String)f.get("abbtlFacs");

and i am getting the single string value.

but when the above field has multiple values ,
i want to get all those values in my action class, but i dont know how i should proceed.
Do i need to put it in an array.

do i use optionscollection like

<html:select property="abbtlFacs" styleClass="formstyle" tabindex="18" multiple="multiple" size="8" style="width:300px">
 <html:optionsCollection property="allvalues" value="value" label="label"/>

and define "allvalues"  as an array in my dyna form in struts config like this
<form-bean name="DynaForm" type="org.apache.struts.validator.DynaValidatorForm" dynamic="true">
           <form-property name="abbtlFacs" type="java.lang.String"/>

           <!--fields for logentry report-->
          <form-property name="allvalues" type="java.lang.String[]"/>

any help greatly appreciated

Question by:jaggernat
  • 2
  • 2
LVL 11

Accepted Solution

fargo earned 2000 total points
ID: 16715700
in the action class, doing
org.apache.struts.util.RequestUtils.populate(form, request);

will fill the form with request parameters. Only thing u need to do is to have String[] property [to handle multiple values] for your select list.
LVL 10

Author Comment

ID: 16718945
ok , so what do i do in my action class to get the array values ?

do i impliment the method populate(form, request);
LVL 11

Expert Comment

ID: 16719002
No, it is already available in RequestUtils class of struts.

instead of form below, use your defined form.
org.apache.struts.util.RequestUtils.populate(form, request);
LVL 10

Author Comment

ID: 16729372
>>>>instead of form below, use your defined form

which form below?

ok, if this is my action class with this method getValues, how do i use RequestUtils class to get the values which user
selected in the <html:select>

public ActionForward getValues(ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
DynaValidatorForm f = (DynaValidatorForm) form;

// org.apache.struts.util.RequestUtils.populate(form, request);

return mapping.findForward("success");


Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Choosing the right mix of apps is very much necessary for CPAs for making the most of the latest technology through which they can boost their growth.
If you try to migrate from Elastix to Issabel, you will face a lot of issues. These problems are inevitable but fortunately, you can fix them. In the guide below, I will explain how I performed the migration while keeping all data and successfully t…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Kernel Data Recovery is a renowned Data Recovery solution provider which offers wide range of softwares for both enterprise and home users with its cost-effective solutions. Let's have a quick overview of the journey and data recovery tools range he…
Suggested Courses
Course of the Month11 days, 22 hours left to enroll

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question