mano dasanayake wrote: > Hi, > Use PropertyUtils.setSimpleProperty(yourForm,"proptyName",object); > > And > > PropertyUtils.getsimplePropert(yourform,"proprtyname") --> cast it to the > required type..
ok, but i have a prepare action for the DynaValidatorForm where i initialize one bean, put it to the ArrayList and then set the array list as property of the form. but i´m not allowd to instantiate or cast the form because of this: <action path="/prepareBuyOnline" type="software.BuyOnlineAction" parameter="prepareForm"> <forward name="success" path="/BuyOnline.jsp"/> it seems that a form of type DynaValidatorFrom does´t allow the attribute name="formName" in the prepare statement and that´s why i´m unable to set the form property. i always get a ForwardConfig exception when i try to do this but i need to set this form property in the prepare statement. is there any other way to do this in a DynaValidatorForm? > > Have a look > http://www.ingrid.org/jajakarta/struts/struts1.0/en/target/documentation/api > /org/apache/struts/util/PropertyUtils.html#getSimpleProperty(java.lang.Objec > t,%20java.lang.String) > > > Regards, > Mano thank you regards philippe > > -----Original Message----- > From: Pille [mailto:[EMAIL PROTECTED] > Sent: Monday, December 18, 2006 5:48 AM > To: Struts Users Mailing List > Subject: Re: DynaValidatorForm - cannot find bean > > how can i access the getters and setters in of a DynaValidatorForm from > within an action method? > > when i had a own form class i could do the following in a action method: > > productForm = (MyOwnForm)form; > > productForm.setComboArrayList(comboArrayListWithBeans); > > with a dynamic form i cannot cast anymore or do i have to cast to a > DynaValidatorForm? is it actually possible to do a cast or do i have to > implement a ValidatorForm instead of using a DynaValidatorForm? > thank you > > > Pille wrote: >> Christopher Schultz wrote: >>> Philippe, >>> >>> Pille wrote: >>>> but after submitting the form with wrong input and returning >>>> to the jsp-page i get the following exception: >>>> javax.servlet.jsp.JspException: Cannot find bean under name countries at >>>> > org.apache.struts.taglib.html.OptionsTag.getIterator(OptionsTag.java:374) >>>> after submitting the form with wrong parameters and returning to the >>>> page the beans are gone. is there any possibility to set the beans with >>>> request.setAttribute() again? >>> You are encountering a common problem with a simple solution. In order >>> to display the form the first time, you are loading "extra" data such as >>> the list of countries. When validation fails, Struts will send you back >>> to the "input" page to try again. If your "input" page is just your >>> form, you will be missing that "extra" information. >>> >>> What I usually do is create two actions: one that loads the information >>> to be edited (the actual content of the form) and another to "prepare" >>> the display. This "prepare" action loads this "extra" information such >>> as a country list. >>> >>> So, I'd have something like this: >>> >>> <action path="/edit" type="EditAction" name="MyFormBean"> >>> <forward name="success" path="/prepare.do" /> >>> </action> >>> <action path="/prepare" type="LoadExtraInfoAction" name="MyFormBean"> >>> <forward name="success" path="/edit.jsp" /> >>> </action> >>> <action path="/save" type="SaveAction" name="MyFormBean" >>> validate="true" input="/prepare.do"> >>> <forward name="success" ... /> >>> </action> >>> >>> As you can see, the "input" for SaveAction is now set to the "prepare" >>> action which loads that extra information, so it's available for the >>> form in case any validation errors occur. >>> >>> -chris >> ok. i understand. >> >> how can i set a property of the form, that is used and needed in the jsp >> of the form after editing? >> how can i set a property of a dyna form from within an action? how do i >> make sure that this property will be still set after submission and >> redirecting over 2 sites? >> >> the problem is that i have 4 dynamic combo boxes and i always need to >> iterate over the request parameters with a Regexp to get and reset all >> the parameters of the combo boxes. the contents of the 4 combo boxes >> depend on the previously made selection. >> one row of the combo boxes is hold in an ArrayList which is a property >> of the DynaValidatorForm. the ArrayList itself holds the Beans. after >> making a selection in the last combo box, i call the action and add a >> new element in the array list. in the jsp i iterate over this ArrayList >> and a second line with no selection is displayed. for each combo box i >> submit the form with the javascript onchange event to generate new >> values (or maybe a new row with combo boxes). >> i have one row of 4 combo boxes. after a selection in the last combo box >> of the last row i create a new arraylist item and a new line with new >> combo boxes is displayed. >> the selection possibilities are stored in the bean (ArrayList with >> Beans) too because some selection possibilities are different from >> others e.g. in the third combo box in the first row there are different >> selection values than in the third combo box in second row because of >> different selections in second combo in first and second row. difficult >> to explain, sorry, hope you understand. >> >> --------------------------------------------------------------------- >> 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] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]