You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by Apache Wiki <wi...@apache.org> on 2009/02/10 23:30:18 UTC

[Tapestry Wiki] Update of "Tapestry5SpringSessionScopedObjects" by damirbijuklic

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Tapestry Wiki" for change notification.

The following page has been changed by damirbijuklic:
http://wiki.apache.org/tapestry/Tapestry5SpringSessionScopedObjects

New page:
Spring can have some objects "session scoped", similarly to application state objects in tapestry.

These objects can be shared by both spring servlets and tapestry application.


You can create session scoped object by adding the following annotations to implementation class (or via xml config):
{{{
@Component
@Scope("session")
public class SessionDataImpl implements SessionData {
  ...
}
}}}

When you use such object in another class by
{{{
@Autowired
private SessionData sessionData;
}}}
spring ensures that each session get's it's own object instance for sessionData.


If you try to use such objects from tapestry with following annotations
{{{
@Inject
@Service("sessionDataImpl")
}}}
it will fail because spring needs to create proxy objects for accessing session scoped objects from global objects.


This can be resolved by adding string RequestContextFilter before TapestryStringFilter for tapestry urls, like this:
{{{
  <filter>
    <filter-name>app</filter-name>
    <filter-class>org.apache.tapestry5.spring.TapestrySpringFilter</filter-class>
  </filter>
  <filter>
    <filter-name>requestContextFilter</filter-name>
    <filter-class>org.springframework.web.filter.RequestContextFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>requestContextFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>app</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
}}}



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org