Hi everyone, I have it working now and share all steps needed:

1. Create your own strategy (e.g. MyStrategy) extending
SessionApplicationStatePersistenceStrategy and implementing
ApplicationStatePersistenceStrategy

2. Bind the strategy in the AppModule's bind method:
binder.bind( ApplicationStatePersistenceStrategy.class, MyStrategy.class);

3. Add the contributeApplicationStatePersistenceStrategySource method to the
AppModule for defining a name for the Strategy (e.g. mySession):

public static void contributeApplicationStatePersistenceStrategySource(
            MappedConfiguration<String, ApplicationStatePersistenceStrategy>
configuration,

            @Local
            ApplicationStatePersistenceStrategy sessionStrategy)
    {
        configuration.add("mySession", sessionStrategy);
    }

4. Contribute the Class (of which you want to persist an Object via your
strategy) to the ApplicationStateManager, using your session key
(mySession):

public static void
contributeApplicationStateManager(MappedConfiguration<Class,
ApplicationStateContribution> config)
    {           
        ApplicationStateCreator<UserSession> creator = new
ApplicationStateCreator<UserSession>() {
                public UserSession create() {
                        return new UserSession();
                }
        };      
        config.add(UserSession.class, new
ApplicationStateContribution("mySession", creator));
    }


5. Now you can use your strategy in the pages like this:
@SessionState
private UserSession userSession;


Cheers,
Tom




--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Best-practise-to-extend-tapestry-5-so-http-sessions-are-stored-in-db-tp2422175p5507740.html
Sent from the Tapestry - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to