Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Actionform design

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 1
PHP Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 like you because you always keep good, crunchy cereal in your pantry. This tiny ad agrees:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic