• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

design question - messages to the user in the page

 
Ranch Hand
Posts: 125
1
Clojure Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to have a message displayed on a page in a progression of forms change based on certain settings. So a user enters some data on page 1, some data on page 2, and on page 3 and 4 they get a specific message based upon some of the information they provided on pages 1 and 2. The message choices are fixed and do not contain any dynamic text.

I could have missed something. In fact, I'm sure there's a lot I missed. But right now, I see three ways to do this:
1. Create session attributes for the fields I want to print and place corresponding bean:write tags on the pages. When the user submits their information on page 2, the ActionClass sets the appropriate session attribute.

2. Create session attributes for an integer. Place the possible messages the user will see inside c:if tests. When the user submits their information on page 2, the ActionClass sets the appropriate variable to an integer.

3. Add form fields corresponding to the message. When the user submits their information, set those form fields to the message. Use a bean:write normally.

.... I don't really care which way I do it, I've got it working with the first method. But if anyone can educate me as to why a particular method is preferred or should be avoided, I would appreciate the information.

Thanks.
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I prefer option 3 provided the ActionForm is already defined in session scope. When you stuff too many different objects into the session, it's hard to keep track of them and even harder to clean them up when you're done using them. If everything needed by the page is in the ActionForm it's simpler to understand the page. Also, when the processing is complete, it's easier to remove that one object from the session than it is to remove several different objects.
 
Michael Swierczek
Ranch Hand
Posts: 125
1
Clojure Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the feedback. You're describing what was nagging me. Using session attributes works fine, but I have attribute creep and I'm afraid the code is getting to the point where only I can keep track of all of them.

There were 22 session attributes when I took over development of the app in October, and with this latest change we're up to 32. I'll look into cases where I can associate the item with a related ActionForm.
reply
    Bookmark Topic Watch Topic
  • New Topic