struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pille <>
Subject Re: DynaValidatorForm - cannot find bean
Date Sun, 17 Dec 2006 23:47:52 GMT
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;


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(
>>> 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="/" />
>> </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="/">
>>     <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:
> For additional commands, e-mail:
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message