<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- We need a doctype to allow us to use special characters like   
     We use a "strict" DTD to make IE follow the alignment rules. -->
     
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd">
<body class="container">
    <h3>Sharing Across Multiple Pages (1)</h3>
    This page demonstrates how to share a bit of data between multiple pages using a Session State Object (an SSO).<br/>
    SSOs are shared between the pages of your web session only, and not with other sessions using the same application.<br/><br/>
    
    To turn a field into an SSO, annotate it with <code>@SessionState</code>.  If any other page or component in your web session 
    declares a field of the same type and annotates it with <code>@SessionState</code> then it will share the same value.<br/><br/>
    
    We use the example of a simple ShoppingBasket object, created in this page and displayed in the next page.
    <div class="eg">
        <t:form class="form-horizontal">
            <div class="form-group">
                <t:label for="applesQuantity" class="col-sm-2"/>
                <div class="col-sm-2">
                    <t:textfield t:id="applesQuantity" value="myBasket.applesQuantity"/>
                </div>
            </div>
            <div class="form-group">
                <t:label for="orangesQuantity" class="col-sm-2"/>
                <div class="col-sm-2">
                    <t:textfield t:id="orangesQuantity" value="myBasket.orangesQuantity"/>
                </div>
            </div>
            <div class="form-group">
                <t:label for="bananasQuantity" class="col-sm-2"/>
                <div class="col-sm-2">
                    <t:textfield t:id="bananasQuantity" value="myBasket.bananasQuantity"/>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-4 col-sm-offset-2">
                    <t:submit value="Next >" />
                </div>
            </div>
        </t:form>
    </div>
    
    Tapestry creates this ShoppingBasket object the first time the page uses it.  Other sessions will not see it, 
    but any pages in your session will use it if they declare a field of type ShoppingBasket annotated with 
    @SessionState.<br/><br/>
    <strong>Caution:</strong> A consideration is the impact in clustered servers.  Howard discusses this in 
    <a href="http://thread.gmane.org/gmane.comp.java.tapestry.user/65410/focus=65426">Tapestry App Replication</a> 
    and the documentation discusses it in 
    <a href="http://tapestry.apache.org/persistent-page-data.html#PersistentPageData-ClusteringIssues">Clustering Issues</a>.<br/><br/>
    
    References: 
    <a href="http://tapestry.apache.org/session-storage.html">Session Storage</a>.<br/><br/>
    
    <t:eventlink event="GoHome">Home</t:eventlink><br/><br/>
    
    <t:tabgroup>
        <t:sourcecodetab src="/web/src/main/java/jumpstart/web/pages/examples/state/SharingAcrossMultiplePages1.tml"/>
        <t:sourcecodetab src="/web/src/main/java/jumpstart/web/pages/examples/state/SharingAcrossMultiplePages1.java"/>
        <t:sourcecodetab src="/web/src/main/resources/META-INF/assets/css/examples/plain.css"/>
        <t:sourcecodetab src="/web/src/main/java/jumpstart/web/state/examples/state/ShoppingBasket.java"/>
    </t:tabgroup>
</body>
</html>