Thanks Rick. As I said in another response, I think I will go with a shared add/update form.

Also, I think we meant the same thing, as far as action mappings go, I just didn't explain very clearly. Indeed, I think now I will just map an action to every screen and the user will never see "*.jsp" at the end of a URI, but rather things like "/viewdetails" or what have you.

You wrote:

Using BeanUtils.copyProperties(), it's a piece of cake to update your Form bean from the ValueObject properties.

Do you have an example of this, or is there one on your site? I indeed have some properties that are the same between form bean and VO, but some are not (for example my form beans use only Strings, but my VOs use some booleans, ints, etc.)

Thanks for your help,

Erik




Rick Reumann wrote:

On Mon, 12 Jul 2004 10:31:29 -0400, Erik Weber <[EMAIL PROTECTED]> wrote:

1) Use two different JSPs to house these forms, even though there will be a lot of redundancy, because the fields may have some variation, and because I'm not fond of having conditionals in the form (if (add) { } else { //must be update). I suppose the common block of fields could be refactored into an include. Any opinions on this are welcome.


It depends on 'how' different the forms will be. If they are the same except for a few fields, I'd reuse the same form, even if it means some JSTL <c:choose><c:when test="${userAction == 'update'}>...</..>
I find it ends up being easier in the long run. Too many time some manager will come to me and say, we need to move the columns around, or this item should be above this item. I like to edit this all in one place, vs two. That being said, if the forms are mostly different except for a few fields, then seperate forms may work out better.



2) Prepopulate the "update" form by assigning an action to it. I suppose the action would, in the execute method, call a business object, get a value object and use the attributes of this object to set all the fields of the ActionForm before returning a forward to the update form screen. Is this the right approach?


I think so. Using BeanUtils.copyProperties(), it's a piece of cake to update your Form bean from the ValueObject properties.

I would especially like opinions here. My view screens have ".jsp" extensions but my screens that have submittable forms have actions that use path mapping, such as "foo/login" and "foo/register" and "foo/save", and so forth. Is it common to map viewing/prepopulating actions one way and saving/writing actions another?


I'm an unclear what you mean be the above. All my pages are jsp pages with .jsp extension but the user never ever will see that in the URL since everything I do forwards through an action. Even just views should forward through an action even if it's just the simple generic ForwardAction.

I have heard of the use of the "reset" method in an Action for prepopulating a form, and indeed it looks convenient.


It should never pre-populate it with business data, but it's ok to use it for making sure certain values are reset to defaults... such as checkboxes, radio buttons, etc. You really need to make use of the reset method if you have checkboxes on your form and you are using validation or the form has session scope. Just don't think of pre-populating meaning prepopulating from your backend - that stuff should be done in your Action. I usually use some form of DispatchAction and usually always have a SetUp() method that does all my population from the ValueObject(s).


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



Reply via email to