myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mat...@apache.org
Subject cvs commit: incubator-myfaces/webapps/simple tree2.jsp
Date Tue, 15 Mar 2005 09:09:04 GMT
matzew      2005/03/15 01:09:04

  Modified:    tlds     myfaces_ext.tld
               src/components/org/apache/myfaces/custom/tree2 HtmlTree.java
               webapps/simple tree2.jsp
  Log:
  Patch for tree2 form Sean Schofield
  
  Revision  Changes    Path
  1.179     +1 -1      incubator-myfaces/tlds/myfaces_ext.tld
  
  Index: myfaces_ext.tld
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/tlds/myfaces_ext.tld,v
  retrieving revision 1.178
  retrieving revision 1.179
  diff -u -r1.178 -r1.179
  --- myfaces_ext.tld	15 Mar 2005 05:24:03 -0000	1.178
  +++ myfaces_ext.tld	15 Mar 2005 09:09:03 -0000	1.179
  @@ -1748,7 +1748,7 @@
           <body-content>JSP</body-content>
           <attribute>
               <name>id</name>
  -            <required>false</required>
  +            <required>true</required>
               <rtexprvalue>false</rtexprvalue>
           </attribute>
           <attribute>
  
  
  
  1.8       +42 -8     incubator-myfaces/src/components/org/apache/myfaces/custom/tree2/HtmlTree.java
  
  Index: HtmlTree.java
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/src/components/org/apache/myfaces/custom/tree2/HtmlTree.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- HtmlTree.java	10 Mar 2005 09:24:19 -0000	1.7
  +++ HtmlTree.java	15 Mar 2005 09:09:04 -0000	1.8
  @@ -23,6 +23,8 @@
   
   import java.util.HashSet;
   import java.util.Map;
  +import java.io.IOException;
  +
   
   /**
    * Represents "tree data" in an HTML format.  Also provides a mechanism for maintaining
expand/collapse
  @@ -36,6 +38,7 @@
   {
       public static final String COMPONENT_TYPE = "org.apache.myfaces.Tree2";
       private static final String DEFAULT_RENDERER_TYPE = "org.apache.myfaces.Tree2";
  +    private static final String NODE_STATE_KEY = "org.apache.myfaces.tree.NODE_STATE_KEY";
       private UICommand _expandControl;
       private String _varNodeToggler;
       private HashSet _expandedNodes = new HashSet();
  @@ -84,9 +87,40 @@
           }
       }
   
  +    public void processDecodes(FacesContext context)
  +    {
  +        super.processDecodes(context);
  +
  +        // store the expand/collapse state information in the session (long story)
  +        Map sessionMap = context.getExternalContext().getSessionMap();
  +        sessionMap.put(NODE_STATE_KEY + ":" + getId(), _expandedNodes);
  +    }
  +
  +    public void encodeBegin(FacesContext context)
  +            throws IOException
  +    {
  +        /**
  +         * The expand/collapse state of the nodes is stored in the session in order to
ensure that this information
  +         * is preserved across requests where the same tree is reused in a tile (server-side
include.)  When using
  +         * the server-side toggle method without this step, the tree would not remember
the expand/collapse state.
  +         * Since we didn't think it was appropriate to burden the end user with this information
as part of a backing
  +         * bean, it just being stored in the session during encode and retrieved during
decode.
  +         */
  +        // restore the expand/collapse state information from the session
  +        Map sessionMap = context.getExternalContext().getSessionMap();
  +        HashSet nodeState = (HashSet)sessionMap.get(NODE_STATE_KEY + ":" + getId());
  +
  +        if (nodeState != null)
  +        {
  +            _expandedNodes = nodeState;
  +        }
  +
  +        super.encodeBegin(context);
  +    }
  +
       /**
  -     * Gets the expand/collapse control that can be used to handle expand/collapse nodes.
 This is only used in server-side 
  -     * mode.  It allows the nagivation controls (if any) to be clickable as well as any
commandLinks the user has set up in 
  +     * Gets the expand/collapse control that can be used to handle expand/collapse nodes.
 This is only used in server-side
  +     * mode.  It allows the nagivation controls (if any) to be clickable as well as any
commandLinks the user has set up in
        * their JSP.
        *
        * @return UICommand
  @@ -135,18 +169,18 @@
       {
           super.processChildNodes(context, parentNode, processAction);
       }
  -    
  +
       /**
  -     * Implements the {@link ActionListener} interface.  Basically, this method is used
to listen for 
  -     * node selection events (when a user has clicked on a leaf node.)  
  -     * 
  +     * Implements the {@link ActionListener} interface.  Basically, this method is used
to listen for
  +     * node selection events (when a user has clicked on a leaf node.)
  +     *
        * @param event ActionEvent
        */
       public void setNodeSelected(ActionEvent event)
       {
           _selectedNodeId = getNodeId();
       }
  -    
  +
       /**
        * Indicates whether or not the current {@link TreeNode} is selected.
        * @return boolean
  
  
  
  1.2       +2 -2      incubator-myfaces/webapps/simple/tree2.jsp
  
  Index: tree2.jsp
  ===================================================================
  RCS file: /home/cvs/incubator-myfaces/webapps/simple/tree2.jsp,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- tree2.jsp	12 Mar 2005 11:40:00 -0000	1.1
  +++ tree2.jsp	15 Mar 2005 09:09:04 -0000	1.2
  @@ -64,7 +64,7 @@
       <b>Client-Side Tree</b>
       <br/>
   
  -    <x:tree2 value="#{treeBacker.treeData}" var="node" varNodeToggler="t">
  +    <x:tree2 id="clientTree" value="#{treeBacker.treeData}" var="node" varNodeToggler="t">
           <f:facet name="person">
               <h:panelGroup>
                   <f:facet name="expand">
  @@ -115,7 +115,7 @@
       <br/>
   
       <!-- Expand/Collapse Handled By Server -->
  -    <x:tree2 value="#{treeBacker.treeData}" var="node" varNodeToggler="t" clientSideToggle="false">
  +    <x:tree2 id="serverTree" value="#{treeBacker.treeData}" var="node" varNodeToggler="t"
clientSideToggle="false">
           <f:facet name="person">
               <h:panelGroup>
                   <h:commandLink immediate="true" action="#{t.toggleExpanded}">
  
  
  

Mime
View raw message