I had the same problem you had, and I didn't want to save lists in session,
for many reasons. After some researches, the solution I choosed is the
following: in forms where I have dropdown lists, I disable the automatic
validation. This can be done adding the parameter validate="false"  in the
correponding action tag in the struts-config file.

<action path="/userpass" type="ui.actions.UserAction" name="passwdForm"
           scope="request" validate="true"
input="/WEB-INF/jsp/userpass.jsp" parameter="action">
           <forward name="form" path="/WEB-INF/jsp/userpass.jsp" />
           <forward name="success" path="/user.do?action=view"
redirect="true"/>
           <forward name="failure" path="/WEB-INF/jsp/userpass.jsp" />
       </action>

The default value is true. This way, all requests are processed directly by
the action. In order to validate the form, the first thing my action does is
to call the validate method:

ActionMessages errors = form.validate(mapping, request);
       if (errors != null && !errors.isEmpty()) {
           saveErrors(request, errors);
           setUp(request, main);
           return (mapping.getInputForward());
}

The setUp method is used to put all your dropdown lists content in the
request.

Hope it helps.

[]s

Miguel

On 5/30/06, Ralf Stoltze <[EMAIL PROTECTED]> wrote:

hi there,

i'm fairly new to struts and it seems like i do have a more conceptual
problem which should be easy to solve...

i have a form including a dropdown list, fetching the entries from a
database.
i like to use DynaForms and validation.

in order to display the dropdown values, i

- link to an action which fetches the data, saves it in request scope
and forwards to my jsp rendering the form (using html:collections to get
the data from the bean)

- let this form call another action to process the input

when validation succeeds, everything works. when validation fails, the
form (+ error messages) should be displayed again.
because my dropdown values were stored in request scope, they cannot be
obtained again and an error occurs ("cannot find bean").

the form data from the select is stored as a simple int value in my
DynaValidatorForm (representing the id in the underlying database
table).

my workaround is to put the dropdown entries into session scope, but i
cannot believe that this is best practice...

can anybody give my a hint?

2nd question: what is the difference between casting my form from the
action's execute method to DynaValidatorForm and casting to
DynaActionForm? both works in my case (i have defined a
DynaValidatorForm in my struts-config).

thanks,
Ralf


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




--
Miguel Galves - Engenheiro de Computação
Já leu meus blogs hoje?
Para geeks http://log4dev.blogspot.com
Pra pessoas normais
http://miguelgalves.blogspot.com

"Não sabendo que era impossível, ele foi lá e fez..."

Reply via email to