• 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

How can I store temporary data during user input procedure?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please, help me with suggestion.
My logic is:

1.PrepareLawAction is invoked.
This action gets Law object from DB (if action received lawId parameter ) or it prepares template Law object (just automatically fills some Law fields which user can't modify).

2.Action sends user to processlaw.jsp
Here user inputs other fields of Law object or modifies them. All fields like <s:textfield/>, <s:select/> and others are inside <s:form/>

Now, problems which I can't solve:
1.PrepareLawAction already made the Law instance. This object can be accessed from processlaw.jsp, but the next action (StoreLawAction) after processlaw.jsp will not "see" my Law object. Is it good practice to store Law object in session (PrepareLawAction will do it) and then retrieve it in StoreLawAction?

2. When user is on the processlaw.jsp he can go to other jsp page to specify special complicated input. I want to allow user to go to this page, but I don't want to loose user input on processlaw.jsp. How can I do it?

Please, see my drawing:
 
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sounds to me like the HTTPSession would be a good place to store this information temporarily until it's persisted in the database. Granted, one should use the session sparingly, but I think it's warranted in this case.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One approach might be tempted to use would be to create a table in my database such that:



Then I store "temporary" items in there. I also make sure I have a listener set up and on the destroySession event I make sure I delete all the values for that session from the table.

I've used this approach with Perl/CGI code in the past (minus the listener) with some degree of success and it avoids using cookies and also avoids possible security issues associated with information leaks.
 
Sergey Sheypak
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using ejb3, so usage of temporary DB tables is not good practice. I have to restore object through ejb local interfaces, or I have to prepare template Law object with filled common fields.
So, I think the solution is:
Law object (restored from DB or Law template) will be placed inside session. All its custom fields will be "action-located", I mean actions will put them on jsp and actions will read them from jsp. If validation and conversion passes, I will put values into Law object, other way user will have to repeat input until it will be correct.
Thanks!

Other problem, validation is not working on WebSphere App server 6.1
I've read that I need x-work 2.0.6-SNAPSHOT to overcome this problem, does anybody have it? I don't want to compile it manually using maven.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic