something is not quite right...
you are NOT required to have the bean placed in session for declarative validations unless you are using indexed properties in your form.
you are using a java bean to populate your form? not form-bean configurations and struts-html tag-lib to build your form?
i apologize if some of these steps are elementary, but here's how i normally set up my validation (through many trials and errors). imagine you have a login form where the username is presented based on a userid stored in a cookie from the last access (an unlikely scenario, but it covers db retrievals).
1. set up 1 form-bean
<form-bean name="LoginForm" type=".....DynaValidatorForm">
<form-property name="username" .../>
<form-property name="password" .../>
</form-bean>
2. set up 2 action mappings that are mapped to the same form-bean
a. <action path="login/entry" name="LoginForm" type="com.my.actions.LoginEntryAction" ...>
b. <action path="login/submit" name="LoginForm" type="com.my.actions.LoginSubmitAction"...validate="true" input="/login/entry.do">
3. in your LoginEntryAction.execute()
a. retrieve the username from the DB
b. do form.set("username", dbVO.getUserName());
c. forward...
4. your tiles/jsp should contain...
a. <html:form action="login/submit"...>
b. <html:input property="username"/> and <html:input property="password"/>
5. configure your validation.xml (i assume you know how)
when the user access login/entry.do, the form will be presented with the username pre-populated. assuming you have "password" defined as 'required', struts will automatically re-populate the form with the username upon failed validation (password field left blank).
of course you can also use DispatchAction and validwhen to do your validation depending on the dispatch method called.
the key to this whole thing is the usage of 2 action mappings and the use of the struts-html tag library. if you have 1 action mapping, validation will be called at all time (the user will always get the error message - password is required). if you are using plain old HTML and view beans to manually populate your forms, you're in for many nightmares to come, especially comes the time of indexed properties.
here's an article with even more explanations, but follows the same approach (that i learned the hard way nearly 2 years ago) -
http://www.oracle.com/technology/oramag/oracle/04-jan/o14dev_struts.html [ May 02, 2005: Message edited by:
alan do ]