I'm sorry if this is too basic, I'm still really green.

I'm validating a form.  This form is used for adding and editing widgets.  I
use the same actionHandler, where I test a request parameter and set up the
form accordingly.  It builds my form object and either resets it for an add,
or retrieves a widget from the DB and sticks it in my object.

What I found was, when my validation failed on add or edit, it was still
going thru the execute() method of my actionHandler and was therefore
reset()ing on add or re-building my form object on edit.

So, I put in something like this instead:

      if ((request.getParameter("Submit") == null) ||
          (!request.getParameter("Submit").equals("Submit"))) {

        if (request.getParameter("addEdit").equals("edit")) {
          form = buildCompanyForm(request.getParameter("id"), request);
        } else {
          form = new CompanyForm();
          form.reset(mapping, request);
        }
      }

And it works, but testing whether Submit has been pressed seems kinda nasty.
I'd like to learn a better way.

Thanks in advance,
Janice


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

Reply via email to