dcsimg
Best practice for update/edit actions.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   John_Corro
Posted On:   Tuesday, July 15, 2003 01:28 PM

Suppose I want to allow a user to update their profile. From a design perspective, my understanding is that I would want to create the following components: ProfileSetupAction: Retrieve user data from storage and populate it into the appropriate ActionForm ProfileForm: ActionForm object that contains user info. *NOTE: The form has a collection of ContactInfo objects (container for address, email, phone, etc data for say office, home, etc) ProfileProcessAction: Invoke appropriate methods to save the user entered data profile.jsp: JSP page to provide display Best Practice Question 1: I've always run into problems directly populating the Pro   More>>

Suppose I want to allow a user to update their profile. From a design perspective, my understanding is that I would want to create the following components:


  • ProfileSetupAction: Retrieve user data from storage and populate it into the appropriate ActionForm
  • ProfileForm: ActionForm object that contains user info.
    *NOTE: The form has a collection of ContactInfo objects (container for address, email, phone, etc data for say office, home, etc)
  • ProfileProcessAction: Invoke appropriate methods to save the user entered data
  • profile.jsp: JSP page to provide display


Best Practice Question 1:
I've always run into problems directly populating the ProfileForm's collection of ContactInfo objects (ie "). I run into an IndexOutOfBoundsException when I try to submit the data because the collection of ContactInfo objects would be cleared out in the reset. When the ActionSetter invokes the appropriate setters it'll try to access an object in an empty collection. Two ways I've come to deal w/ this is dynamically increase the size of the collection directly in the getter or prepopulate the collection in the reset() method. Both styles have messy consequences. Either way, I'd prefer to keep all population of data confined to the ProfileSetupAction.




Best Practice Question 2:
Say I wanted to forward the user back to ProfileSetupAction after ProfileProcessAction (to redisplay their saved data). A problem here is that the ActionForm's reset() method is invoked and the HTML form data gets reposted after the ProfileProcessAction, but before the ProfileSetupAction. This can also cause a number of problems. Is there any way to prevent the data from being reposted coming into the ProfileSetupAction?    <<Less
About | Sitemap | Contact