This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
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.
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
Joined: Oct 27, 2009
Posts: 22
posted
0
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.
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.