Hi,
What I've typically done for this is the following:
Class ActionBean {
DateRange dateFilter;
@Before(stages={LifecycleStage.BindingAndValidation})
void prepareBean() {
setDateFilter(getContext().getDateFilter());
}
@Before(stages={LifecycleStage.ResolutionExecution})
Void saveBean() {
getContext().setDateFilter(getDateFilter());
}
}
class ActionBeanContext {
DateRange getDateFilter() {
return (DateFilter) getSessionAttribute(AttrNames.SES_DATE_FILTER);
}
void setDateFilter(DateRange dateFilter) {
setSessionAttribute(AttrNames.SES_DATE_FILTER, dateFilter);
}
}
Those interceptor methods pull it out of the context before binding, the
binding phase potentially overwrites it if something came in via the post, and
whatever is in the bean gets sent back out to the context before the page is
displayed. easy
John
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Poitras Christian
Sent: Friday, November 02, 2007 10:09 AM
To: [email protected]
Subject: [Stripes-dev] Session annotation
Hi!
I've added an annotation and an interceptor to Stripes to store ActionBean
fields in session and restore them automatically on subsequent requests.
I wanted to share this "plugin" with people of stripes. Where can I post such
information and classes.
The annotation is below.
Christian
/*
* <p>Copyright: Copyright (c) 2007</p>
* <p>Company: Institut de recherches cliniques de Montréal (IRCM)</p>
*/
package ca.qc.ircm.lims.web.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Annotation used to indicate that an attribute should be stored in session.
*
* @author poitrac
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
public @interface Session {
/**
* Indicate if attribute is serializable.
*/
boolean serializable() default false;
/**
* Maximum time in minutes the object will stay in session if not accessed.
*/
int maxTime() default -1;
}
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development