-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Rick,

Rick Schumeyer wrote:
> I am looking for an example of an edit cycle.  Let's say I have a list
> of employee names; If I click on one I want to have a page to edit the
> employee values.
> 
> The initial click would call an action that queries the database, gets
> the employee data, and stores it...where exactly?
> 
> The initial click did not come from a form, and so does not have an
> associated ActionForm (or should it?)

Your spidey-sense is tingling correctly, Rick.

The way that Struts is intended to be used is that you associate a form
bean with your "edit" action, but set it to validate="false". Then, in
your action, grab the (empty) form bean and fill it with information
from your database (or wherever). Then, forward (not redirect) to your
display page (JSP, velocity, whatever).

In your view page, use the data in the form bean as the values for all
of your form fields.

When you save, and validation fails, the form bean will contain
non-validated data. I assume that you have set your edit forward and
your save action's "input" to the same thing: this makes it easy to use
the same page to display fresh-from-the-database data as well as
re-displaying invalid submission data for correction.

> The edit page will have an associated ActionForm, but we are not there yet.

You can have your <action> element contain a "name" (form bean) as well
as a "forward" (shortcut to your page... i.e. no custom action) and it
will work properly (your form bean will be empty).

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFffZr9CaO5/Lv0PARAswJAJwNxaBt4zmfirX6L7psBFrY30JWYgCgjOnT
y+uxpIqj2OGTSmCuyVxBH0s=
=2egv
-----END PGP SIGNATURE-----

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

Reply via email to