You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Ashish Raniwala <ar...@gmail.com> on 2005/02/19 04:59:57 UTC

Tree Problem

Guys,
I am facing problem while using ISessionStore for tree component. May be I am missing something here. 
Problem is when I click on the root node the tree expand one level and now if I click on any child node whole tree collapses.
Which means that component is not getting correct stateModel somehow.
I am using default FullTreeSessionStateManager so I guess component should persist stateModel and dataModel in sessionStore and retrieve from there.

While looking into this problem I found something suspicious...

Look at this method below which is from contrib.TreeView

    private void extractTreeModel(){
        if (LOG.isDebugEnabled()) {
            LOG.debug("TreeView.extractTreeModel()");
        }

        ISessionStoreManager objHolder = getSessionStoreManager();
        ITreeSessionStateManager objSessionManager = getTreeSessionStateMgr();
        Object objSessionState;
        if (objHolder == null) {
            objSessionState = getTreeSessionState();
        } else {
            objSessionState = objHolder.getSessionState(this.getPage(),
                                                        "treeSessionState");
        }

        if (objSessionState != null) {
            m_objTreeModel = objSessionManager.getModel(objSessionState);
        } else {
            if (LOG.isDebugEnabled()) {
                LOG.debug("TreeView.extractTreeModel() from BINDING");
            }

            m_objTreeModel = (ITreeModel)getTreeModelBinding().getObject();
        }

    }

Here objSessionState is retrieved from sessionStore (objHolder) with the key name hard coded as "treeSessionState"

But no where it set the objState with key treeSessionState in the store instead it saves the model with extended ID (getPageName() + "/" + getIdPath()) key in store() method.
So objSessionState is always NULL.

Once objSessionState is NULL it get tree model from the binding which initialize the state model...


Here is my Tree class if I am missing something there:

public abstract class ProcessTree extends BaseComponent implements
        PageDetachListener {

    private ITreeModel treeModel = null;

    public void pageDetached(PageEvent event) {
        treeModel = null;
    }

    public void finishLoad(IRequestCycle cycle, IPageLoader loader,
            IComponentSpecification specification) {
        super.finishLoad(cycle, loader, specification);
        getPage().addPageDetachListener(this);
    }

    /**
     * Method getTreeModel.
     * 
     * @return ITreeModel
     */
    public ITreeModel getTreeModel() {
        if (null == treeModel) {
            treeModel = new EpianceTreeModel(getTreeDataModel());
        }
        return treeModel;
    }

    /**
     * Method getTreeDataModel.
     * 
     * @return ITreeDataModel
     */
    private ITreeDataModel getTreeDataModel() {
        ITreeDataModel treeDataModel = getVisit().getProcessTreeDataModel();
        if (null == treeDataModel) {
            treeDataModel = (ProcessDataModel) getApplicationContext().getBean(
                    "processDataModel"); //$NON-NLS-1$
            getVisit().setProcessTreeDataModel(treeDataModel);
        }
        return treeDataModel;
    }

    /**
     * Method getSessionStoreManager.
     * 
     * @return ISessionStoreManager
     */
    public ISessionStoreManager getSessionStoreManager() {
        ISessionStoreManager processSessionStore = getVisit()
                .getProcessTreeSessionStore();
        if (null == processSessionStore) {
            processSessionStore = new EpiSessionStoreManager();
            getVisit().setProcessTreeSessionStore(processSessionStore);
        }
        return processSessionStore;
    }


}

___________________________________________________________________-

Please suggest how to workaround this ? Anyone faced this issue before ?

thanks,
Ashish