Author: drobiazko
Date: Thu Dec 31 16:12:35 2009
New Revision: 894879

URL: http://svn.apache.org/viewvc?rev=894879&view=rev
Log:
Added documentation of @SessionAttribute.

Modified:
    tapestry/tapestry5/trunk/src/site/apt/guide/persist.apt

Modified: tapestry/tapestry5/trunk/src/site/apt/guide/persist.apt
URL: 
http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/src/site/apt/guide/persist.apt?rev=894879&r1=894878&r2=894879&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/src/site/apt/guide/persist.apt (original)
+++ tapestry/tapestry5/trunk/src/site/apt/guide/persist.apt Thu Dec 31 16:12:35 
2009
@@ -148,3 +148,34 @@
   service is ultimately responsible for determining whether a session 
persisted object is dirty or not (dirty meaning
   in need of a restore into the session). This is an extensible service where 
new strategies, for new classes,
   can be introduced.
+  
+Session Data
+
+  When integrating Tapestry with legacy applications it is often required to 
read or to write some data from or into the HttpSession.
+ 
++----+
+public class Page
+{
+    @Inject
+    private Request request;
+    
+    public User getUser()
+    {
+        return (User) request.getSession(true).getAttribute("user");
+    }
+
+}
++----+
+
+  Since 5.2 this can be accomplished just by annotating a page or component 
property with @SessionAttribute. This annotation is 
+  used to map a property of a page or component to value stored in session. 
The name of the annotated property is used as the name of 
+  the session attribute to look for. You can also provide a name by binding 
the <<value>> parameter of the annotation.
+
++----+
+public class Page
+{
+    @SessionAttribute
+    private User user;
+
+}
++----+
\ No newline at end of file


Reply via email to