This has nothing to do with instantiating a form.

His question was:
> >>the DynaValidatorForm in my strus_config to take a unknown number of 
> >>checkbox values?
The HttpServletRequest realizes multiple values under the same name 
(ie. dynamic number of checkboxes) as a java.lang.String[].

If you are using DynaXXXXActionForm then you can declare a property of type
java.lang.String[] in your struts-config file to capture properties with
multiple values under the same property name.

This is done using the following syntax in your struts-config file nested within
the form-bean element.

<form-property name="rrole"
               type="java.lang.String[]" initial="{}"/>


His other question was:
> >>second question: how can I make the properties of a DynaVForm available 
> >>to a Action?
Since your are using DynaXXXXActionForm it implements the DynaBean interface which
provides general getter/setter methods of the form  get() and set().

The form first needs to be cast to the appropriate class or interface and then 
you can use the get() to extract the data.

DynaActionForm form = (DynaActionForm)form;
String[] rrole = (String[])form.get("rrole);


He's getting the exception because the instance of the form passed to the
action does not have the "rrole" property defined.


I apologize if I missed something obvious.

robert



> -----Original Message-----
> From: Takhar, Sandeep [mailto:[EMAIL PROTECTED]
> Sent: Friday, April 02, 2004 2:54 PM
> To: Struts Users Mailing List
> Subject: RE: DynaValidatorFom with checkbox properties
> 
> 
> there have been tonnes of posts on why you cannot instantiate a dynaform like that.
> 
> http://www.javablogs.com/ViewEntry.jspa?id=128211
> 
> here is one example of how you can
> 
> sandeep
> 
> -----Original Message-----
> From: Johannes Wolfgang Woger [mailto:[EMAIL PROTECTED]
> Sent: Friday, April 02, 2004 2:42 PM
> To: Struts Users Mailing List
> Subject: Re: DynaValidatorFom with checkbox properties
> 
> 
> 
> 
> Robert Taylor wrote:
> 
> >>employee. How shall I configure
> >>the DynaValidatorForm in my strus_config to take a unknown number of 
> >>checkbox values?
> >>    
> >>
> >
> ><form-property name="rrole"
> >                  type="java.lang.String[]" initial="{}"/>
> >
> >
> >  
> >
> >>second question: how can I make the properties of a DynaVForm available 
> >>to a Action?
> >>    
> >>
> >DynaActionForm form = (DynaActionForm)form;
> >String[] rrole = (String[])form.get("rrole);
> >
> Doing so, gives me the exception:
>     
> 
> javax.servlet.ServletException: Invalid property name 'rrole'
>       
> org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:545)
>       
> org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:486)
>       org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
>       org.apache.struts.action.ActionServlet.process(ActionServlet.java:1480)
>       org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:524)
>       javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
>       javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
> 
> root cause
> 
> java.lang.IllegalArgumentException: Invalid property name 'rrole'
>       
> org.apache.struts.action.DynaActionForm.getDynaProperty(DynaActionForm.java:598)
>       org.apache.struts.action.DynaActionForm.get(DynaActionForm.java:241)
>       org.zack.action.EmployeeDispatchAction.update(Unknown Source)
>       sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       java.lang.reflect.Method.invoke(Method.java:324)
>       
> org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:280)
>       org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:216)
>       
> org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
>       org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
>       org.apache.struts.action.ActionServlet.process(ActionServlet.java:1480)
>       org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:524)
>       javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
>       javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
> 
> >
> >You might try using <html:multibox .../>
> >
> ><c:forEach var="tk" items="${task}">
> ><html:multibox property="rrole"><c:out value="${tk.taskId}"/></html:multibox>
> ></c:forEach>
> >
> everything else you supose seems to work well, but I cannot look what 
> the DVForm realy loaded,
> how I will put these values into the database is an other story.
> 
> Thank you very much. Wolfgang
> 
> >
> >
> >robert
> >
> >  
> >
> >>-----Original Message-----
> >>From: Johannes Wolfgang Woger [mailto:[EMAIL PROTECTED]
> >>Sent: Friday, April 02, 2004 12:48 PM
> >>To: [EMAIL PROTECTED]
> >>Subject: DynaValidatorFom with checkbox properties
> >>
> >>
> >>Hi,
> >>I have a checkbox, where do not know in adwance how many properties to 
> >>be checked I will have
> >>this is why I use forEach.
> >>I am using a DynaValidatorForm which takes some attibutes for an 
> >>employee. How shall I configure
> >>the DynaValidatorForm in my strus_config to take a unknown number of 
> >>checkbox values?
> >>
> >><c:forEach var="tk" items="${tasks}">
> >>    
> >>       <c:out value="${tk.taskBez}"/>
> >>               <input type="checkbox" name='rrole' value='<c:out 
> >>value="${tk.taskId}"/>'/>                   
> >>      </c:forEach>
> >>
> >>this is how my .jsp looks like.
> >>
> >>second question: how can I make the properties of a DynaVForm available 
> >>to a Action?
> >>
> >>Thanks
> >>    Wolfgang
> >>
> >>
> >>---------------------------------------------------------------------
> >>To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >>    
> >>
> >
> >---------------------------------------------------------------------
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >  
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to