Hello all. I am building a web portal application where each user has their
own cloud environment. I am representing user's cloud environment as a tree
structure. When user login, I prepare their tree based on what ever cloud
resources they have. *Once user select leaf in tree, new page opens up but
Tree automatically resets to unexpanded. If I go back to previous page, it
automatically expands. It almost seems that Tree is querying Page-Session
and not Application-session.* Here is how my code look like.  Please notice
that I have used correct java annotation @SessionState on (private
ValueWrapper valueWrapper) in UserSessionManagement.   I am using in
PortalAccessTree component in Layout component. Layout is what is used to
render all Pages on my site. 

Can you please tell me what I am doing wrong?  I can't store valueWrapper as
static member as it is different for each logged in user. My Tree component
goes to unexpanded state, as soon as i click page link, which has never
visited before. 

public abstract class UserSessionManagement {
        
        @SessionState
        private User user;      
        private boolean userExists;     
        
        public User getUser() {
                return user;
        }
        protected void setUser(User user) {
                this.user = user;
        }       
        public boolean isUserExists() {
                return userExists;
        }       
        
        
        @SessionState   
        private ValueWrapper valueWrapper;
        private boolean valueWrapperExists;
        public ValueWrapper getValueWrapper() {
                return valueWrapper;
        }
        public void setValueWrapper(ValueWrapper valueWrapper) {
                this.valueWrapper = valueWrapper;
        }
        public boolean isValueWrapperExists() {
                return valueWrapperExists;
        }
        
        public boolean isLoggedIn() {
                return getPrimaryUser() != null && 
getPrimaryUser().isLoggedIn();
        }
                
        public PrimaryUser getPrimaryUser() {
                return userExists ? user.getPrimaryUser() : null;
        }

}


public class PortalAccessTree extends UserSessionManagement {
        
        @InjectComponent
        private Tree tree;  
        
        /**
         * Always initialize component using @SetupRender annotation. 
         * @throws VCloudException 
         */
        @SetupRender
    void initializeValue() throws VCloudException
    {   
                if(getUser().getRootNode().getChildren().size() == 0) {
                
                        
TreePreprationHelperUtil.prepareAccessTree(getUser().getRootNode(),
getUser().getPrimaryUser().getCloudDirectorUsers());                    
                                        
                }
        
        }

        public TreeModel<ValueWrapper> getValueWrapperModel() {
                ValueEncoder<ValueWrapper> encoder = new 
ValueEncoder<ValueWrapper>() {
                                                                                
                public String toClient(ValueWrapper value) {
                                                                                
                        return value.getUuid();
                                                                                
                }
                                                                        
                                                                                
                public ValueWrapper toValue(String clientValue) {
                                                                                
                        return getUser().getRootNode().seek(clientValue);
                                                                                
                }
                                                                                
        };

                return new DefaultTreeModel<ValueWrapper>(encoder, new
ValueWrapperTreeModelAdapter(), getUser().getRootNode().getChildren());
        }

        /**
         * Clear Action link on PortalAccessTree.tml invokes this method. 
         */
        void onActionFromClear() {
                tree.clearExpansions();
        }

}

PortalAccessTree.tml
-----------------------
<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd";
xmlns:p="tapestry:parameter">

             
*${primaryUser.portalUsername}'s cloud environments*

                  
                 <t:tree t:id="tree" model="valueWrapperModel" 
value="valueWrapper"
label="block:renderTreeNodeLabel"/>
                 
                 <t:block id="renderTreeNodeLabel">
                      <t:if test="valueWrapper.leaf">
                          # ${valueWrapper.label} 
                         <p:else>
                              ${valueWrapper.label}
                         </p:else>
                     </t:if>
                  </t:block>
                  
                  &nbsp;&nbsp;<t:actionlink t:id="clear">clear 
expansions</t:actionlink> 
                  <br/>   
                    
                  <div style="clear:both;"/>
        </div>
        
</t:container>


Layout.tml
-------------

<html xmlns="http://www.w3.org/1999/xhtml";
      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd";
      xmlns:p="tapestry:parameter">
      
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
        <link rel="shortcut icon" href="/ilandPortal/favicon.ico"
type="image/x-icon" />         
        <title t:type="if" test="title">${title}</title>
        <title t:type="if" test="altTitle">${altTitle}</title>        
    </head>
    <body>

                <div class="page">
                        <t:delegate to="case"/>
                </div>
                
                <t:block t:id="loggedInMemberContainer">                        
                        <t:portalAccessTree/>                                   
                
                        <t:body/>       
               </t:block>

               <t:block t:id="visitorContainer">
                    <t:body/>
               </t:block>

    </body>    
</html>



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Tree-Session-Management-Issue-tp5715132.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