aspose file tools*
The moose likes Struts and the fly likes Actionform design Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Actionform design" Watch "Actionform design" New topic
Author

Actionform design

G Par
Greenhorn

Joined: Jul 11, 2011
Posts: 9
Hi All,
I am struggling with designing an ideal solution for Action/Form.

The requirement is roughly like this:
You have a Customer page appearing first with data pre-populated.
Followed by Bank Details page , also pre-populated
and finally, Address page

So I could come up with something like this:
Customer.jsp contains html:form with action mapping CustomerAction->CustomerActionForm
Bank.jsp contains html:form with action mapping BankAction->BankActionForm
Address.jsp contains html:form with action mapping AddressAction->AddressActionForm

the Action forms have logic to save data submitted from respective forms.

The problem is to pre-populate the respective ActionForms before the pages are opened, I have to retrieve customer data before customer action, supplier data before supplier action and so on.. I would probably have to retrieve supplier data inside customer action after it is succesfully saved. I find that quite non-intuitive and non-reusable.
Alternative approach is to retrieve all the ActionForms and store them in session even before the first form. But this has disadvantage of retrieving all data up-front which means if the user cancels in between it's a waste.

Can anybody suggest any other design?

Thanks
Girish
G Par
Greenhorn

Joined: Jul 11, 2011
Posts: 9
oh cmon guys, I didn't think it was that arcane a question that nobody would bother to reply. I really need to know from experts what's the best practive here. Appreciate a response.
N Hubbs
Greenhorn

Joined: Jul 08, 2011
Posts: 1

Here is how I would design it. Each action should have the logic to retrieve/populate the initial set of data and to process the form submission when the user submits it. An "if" would be needed in each action to decide if we are handling a form submission or a form population. For instance after completing the logic of processing the submission of data in CustomerAction I would redirect to BankAction which would retrieve the bank information and populate it into the BankActionForm then forward to the jsp to display the page. After the user fills in the form the data would be submitted to BankAction which would process the data and redirect to the next action in line. That way your action/forms are mostly self contained and the code within is only concerned with the data related to one entity (like bank or customer).
Hope that helps some.
G Par
Greenhorn

Joined: Jul 11, 2011
Posts: 9
Thanks Hubbs, That does make the action self conainted but with the added "drawback" (is it really?) of needing If branching to differentiate modes plus passing the mode from web page via request, that means more coupling with servlet api.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Actionform design