-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Jim,
Gallagher, Jim (RBoS ITD&S Dublin) wrote: > I'm wondering whether it's a better idea to create the > formbean, populate it and use that to pass the information to the jsp? This really is the "struts way". But, in order to do this, you don't have to do a ton of work. For instance, simply modify your struts-config.xml action mappings to include the "name" attribute for the mapping which initially displays your (empty) form. That will set up the (empty) form bean for further use. You can do nothing at this point, and you'll get an empty form, just like you do, now. Or, you can add code to your action (if you are using one) or to your JSP (though I highly recommend using an action instead of putting code in your JSP) that grabs the form bean just like in your form handling actions. Once you have a reference to this form bean, you can fill it with data. A simple example is loading a record from a DB for editing: 1. Hit the /edit.do URI which has "myForm" as the form bean. 2. Fetch the appropriate record from the database. 3. EditAction takes its "form" parameter and casts it to the appropriate type (MyBeanType). 4. Fill the bean with data from the DB record (don't forget to include the records PK). 5. Display your form, remembering to include all the data you just stuck into the bean, instead of just leaving the fields blank. ~~~~~ 6. Post your form to your form handler (/save.do). If you use struts validation, it can check to make sure that your form fields are (at least mostly) valid and redisplay the form if there's a problem. This is a huge advantage that I recommend you .. umm, take advantage of. 7. Process your form normally. Hope that helps, - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFZF2S9CaO5/Lv0PARAgjjAJ9dJ4r+PUlvkJ2w7360w1weOASzEgCdEVFj /hpfA2psUPbscPSoY5ZfwtQ= =csK4 -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]