struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: DynaValidatorForm - cannot find bean
Date Sun, 17 Dec 2006 21:38:25 GMT
Hash: SHA1


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 path="/prepare" type="LoadExtraInfoAction" name="MyFormBean">
    <forward name="success" path="/edit.jsp" />
<action path="/save" type="SaveAction" name="MyFormBean"
        validate="true" input="/">
    <forward name="success" ... />

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
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla -


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

View raw message