• 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Putting a modeldriven object into session

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

I have a Search action that implements ModelDriven. Once a user enters his search criteria, I want that information put into the Session so that after the user has performed other functions on other pages (add, change, delete, etc...) and the user comes back to the Search page, the search will be performed again with the last search parameters.

To do this, I created an interceptor that will inject the search criteria object into my search action.

The problem I'm having is, *when* do I put my search criteria object into the session? I'm using the paramsPrepareParamsStack and after the first "params" interceptor fires, the request parameters are not in my model object -- yet. They don't get put into the model object until the 'modelDriven' interceptor fires, at least, that's what I see when I debug my action.

Any ideas?
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Add it to the session in the action that processes the form. This kind of behavior doesn't belong in an interceptor.
 
Kev Adams
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
David,

That's what I'm doing. In the action that processes the search form, I'm putting the criteria into the session, and I'm letting an interceptor inject that criteria back into the action when the user comes back to the search page after having done something else.

The problem I'm having is that the content of the search criteria object has not been populated by the 'params' interceptor yet, because params comes before 'modeldriven' in the paramsPrepareParams stack. So, when I put the search criteria object into the session, it contains the wrong information.

Does that make sense?
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess. You can always change the order of the interceptors.

I'm not convinced this interceptor is overly helpful, though--the same work could be done manually in the "prepare" method with a single line of code (assuming you implement SessionAware). Unless it's a general purpose "grab annotated properties from the session" interceptor, it strikes me as too "special-purpose." Interceptors are really designed for application- or large-ish-chunk-of-application-wide functionality, not a single action.
 
WHAT is your favorite color? Blue, no yellow, ahhhhhhh! Tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic