Kim-

I had the same problem with some static form elements (e.g. contents of list boxes that were not part of any model data I cared to keep, yet it needed to be in the JSP page.)

One solution I found was to set the properties on the session, but I decided that that was unnecessarily cluttering up the session and since only one form needed it was overkill. Note the method signature of the validate(...) method in your ValidatorFormBean (or DynaForm...):

public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {

   // will not return null
   ActionErrors errors = super.validate(mapping, request);

   ...
}

It takes a HttpServletRequest object. Thus, you can set any attributes or parameters you need to on the request after a failed (or even successful) validation. What I do is if the validation fails (the ActionErrors instance will not be empty - use this as your flag) and I set the parameters to populate the static form content widgets in my JSP so when the JSP page is reloaded with the error messages displayed, it displays correctly.

Doing this avoids two things: I'm not storing non-bean data in my bean and the data is segregated from the rest of the web container because it's only available to the request. Now, if your situation differs, you can set it on the session instead and all your JSP pages will have access to the content.

Hope this helps.

Cheers,

-Adam

Kim Brianne Go wrote:
Good Day,

I was just wondering if anyone has a clue on how to retain request
values (
request.setAttribute()) forwarded to a jsp form page and once a form has
been submitted or validated then returns with error messages the values
from
request.setAttribute() is no longer accessible.

Here's an example...

A form has an OptionsCollections populated using the
request.setAttribute()...
from an action class.  I applied the Validator (Server-side) to perform
input validations, everything works well aside from the problem specific
to
the OptionCollections... since it requires the values sent to the jsp
page
prior to submission and validation.

A temporary solution was to put the OptionsCollections inside the
bean:present tag to avoid disrupting the entire page's execution.  But
this
is not acceptable in practice since the input field that requires
OptionsCollections is necessary.

Does anyone have an idea how to go about this aside from doing a
bean:present or putting the values in session?

Thanks,

Brian


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

Reply via email to