Mark Benussi wrote:

I have a web based application which allows the Creation, Update, Read and Deletion of Data objects (Nothing new here).

All data changes are done by calling Manager methods with Action Forms to update the relevant data e.g.

new ShopManager().createOrder(createOrderForm);

or new ShopManager.updateOrder(updateOrderForm);

My problem is that I am having to create duplicate JSPs and actions for the create and update processes. The pages look exactly the same and hold the same values but the difference is that the update actions will pre populate the form with the existing methods and invoke the update method on the manager instead of a standard create. Even the forms are identical (The update form extends the create form but holds a reference to the data id that is to be updated).

My question is: Is there a way to have one set of JSPs, Forms and actions to manage all of this. When I change a JSP I am having to maintain two pages which sounds trivial but to me shouts of bad design. The only difference between the pages is that they call different actions i.e. /order/create/stage1.do vs /order/update/stage1.do


You can use a variable for the action URL in your form tag:

<html-el:form action="${action}" focus="some_field">

Set the variable according to whether you are in add or update mode. The variable can be a request attribute set in your setup Action or can be set with c:set/c:choose or similar. The two different Action URLs can be configured to point to the same Action and to (possibly) share the same form-bean, but each has a different parameter (see the "parameter" attribute) that your Action can switch on.

As someone suggested, the "dispatch" variety of Actions can help with this.

Erik


I would be interersted to know peoples thoughts.

Cheers,

Mark



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



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



Reply via email to