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

x
?
Solved

getting  arraylist/array  values in action class

Posted on 2006-05-18
4
Medium Priority
?
1,340 Views
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">
 </html:select>

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"/>
  </html:select>

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[]"/>
</form-bean>



any help greatly appreciated

thanks
J
0
Comment
Question by:jaggernat
  • 2
  • 2
4 Comments
 
LVL 11

Accepted Solution

by:
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.
0
 
LVL 10

Author Comment

by:jaggernat
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);
0
 
LVL 11

Expert Comment

by:fargo
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);
0
 
LVL 10

Author Comment

by:jaggernat
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");
}

thanks,
J
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

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