You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@shale.apache.org by sc...@apache.org on 2006/08/02 02:42:52 UTC

svn commit: r427823 - in /shale/sandbox/shale-petstore/src/main: java/org/apache/shale/petstore/service/impl/InventoryServiceImpl.java java/org/apache/shale/petstore/view/backing/TreeBacker.java webapp/WEB-INF/faces-config.xml

Author: schof
Date: Tue Aug  1 17:42:52 2006
New Revision: 427823

URL: http://svn.apache.org/viewvc?rev=427823&view=rev
Log:
tree state is now preserved across multiple views (so the expand/collapse information is not lost when you click on a pet)

Modified:
    shale/sandbox/shale-petstore/src/main/java/org/apache/shale/petstore/service/impl/InventoryServiceImpl.java
    shale/sandbox/shale-petstore/src/main/java/org/apache/shale/petstore/view/backing/TreeBacker.java
    shale/sandbox/shale-petstore/src/main/webapp/WEB-INF/faces-config.xml

Modified: shale/sandbox/shale-petstore/src/main/java/org/apache/shale/petstore/service/impl/InventoryServiceImpl.java
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-petstore/src/main/java/org/apache/shale/petstore/service/impl/InventoryServiceImpl.java?rev=427823&r1=427822&r2=427823&view=diff
==============================================================================
--- shale/sandbox/shale-petstore/src/main/java/org/apache/shale/petstore/service/impl/InventoryServiceImpl.java (original)
+++ shale/sandbox/shale-petstore/src/main/java/org/apache/shale/petstore/service/impl/InventoryServiceImpl.java Tue Aug  1 17:42:52 2006
@@ -60,20 +60,20 @@
         Category dogs = new Category("Dogs");
         Category terriers = new Category("Terriers");
         dogs.addChildCategory(terriers);
-//        Pet bostonTerrier = new Pet("0100", "Boston Terrier");
-//        Pet wheatonTerrier = new Pet("0101", "Wheaton Terrier");
-//        terriers.addPet(bostonTerrier);
-//        terriers.addPet(wheatonTerrier);
-//        Category retrievers = new Category("Retrievers");
-//        dogs.addChildCategory(retrievers);
+        Pet bostonTerrier = new Pet("0100", "Boston Terrier");
+        Pet wheatonTerrier = new Pet("0101", "Wheaton Terrier");
+        terriers.addPet(bostonTerrier);
+        terriers.addPet(wheatonTerrier);
+        Category retrievers = new Category("Retrievers");
+        dogs.addChildCategory(retrievers);
         Category birds = new Category("Birds");
         Category fish = new Category("Fish");
         Category reptiles = new Category( "Reptiles");
 
         categoryDao.store(dogs);
-//        categoryDao.store(cats);
-//        categoryDao.store(birds);
-//        categoryDao.store(fish);
-//        categoryDao.store(reptiles);
+        categoryDao.store(cats);
+        categoryDao.store(birds);
+        categoryDao.store(fish);
+        categoryDao.store(reptiles);
     }
 }

Modified: shale/sandbox/shale-petstore/src/main/java/org/apache/shale/petstore/view/backing/TreeBacker.java
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-petstore/src/main/java/org/apache/shale/petstore/view/backing/TreeBacker.java?rev=427823&r1=427822&r2=427823&view=diff
==============================================================================
--- shale/sandbox/shale-petstore/src/main/java/org/apache/shale/petstore/view/backing/TreeBacker.java (original)
+++ shale/sandbox/shale-petstore/src/main/java/org/apache/shale/petstore/view/backing/TreeBacker.java Tue Aug  1 17:42:52 2006
@@ -21,9 +21,7 @@
 import org.apache.shale.petstore.domain.Pet;
 import org.apache.shale.petstore.service.InventoryService;
 
-import javax.faces.context.FacesContext;
 import java.util.List;
-import java.util.ArrayList;
 import java.util.Set;
 
 /**
@@ -42,15 +40,20 @@
      */
     public TreeBacker() {
         /**
-         * There is a technical reason for maintaining our own TreeState (instead of using the default one that
+         * There is a technical reason for maintaining our own TreeStateHolder (instead of using the default one that
          * is provided.)  When using tree2 for navigation purposes you will "lose" the expand/collapse state
          * information if your navigation outcome sends you to a new view.  This only happens with server side
          * toggle but its a signficant issue.  In order for users to see the tree in the same state as it was
-         * before they clicked it, we will want to preserve the TreeState here in this backing bean and give
+         * before they clicked it, we will want to preserve the TreeStateHolder here in this backing bean and give
          * the backing bean session scope.  NOTE: We are not storing the actual tree data in the session, just
          * the state info, which is basically a list of expanded node ids.
          */
-        treeState = new TreeStateBase();
+        //treeState = new TreeStateBase();
+        //treeState.setTransient(true);
+    }
+
+    public void setTreeState(TreeState treeState) {
+        this.treeState = treeState;
         treeState.setTransient(true);
     }
 
@@ -65,8 +68,6 @@
         for (Category category : inventory) {
             rootChildren.add(convertCategory(category));
         }
-
-        // TODO -- replace with call to service bean
 
         TreeModel treeModel = new TreeModelBase(rootNode);
         treeModel.setTreeState(treeState);

Modified: shale/sandbox/shale-petstore/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/shale/sandbox/shale-petstore/src/main/webapp/WEB-INF/faces-config.xml?rev=427823&r1=427822&r2=427823&view=diff
==============================================================================
--- shale/sandbox/shale-petstore/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ shale/sandbox/shale-petstore/src/main/webapp/WEB-INF/faces-config.xml Tue Aug  1 17:42:52 2006
@@ -84,12 +84,21 @@
   </managed-bean>
 -->
   <managed-bean>
+    <managed-bean-name>treeState</managed-bean-name>
+    <managed-bean-class>org.apache.myfaces.custom.tree2.TreeStateBase</managed-bean-class>
+    <managed-bean-scope>session</managed-bean-scope>
+  </managed-bean>
+  <managed-bean>
     <managed-bean-name>treeBacker</managed-bean-name>
     <managed-bean-class>org.apache.shale.petstore.view.backing.TreeBacker</managed-bean-class>
     <managed-bean-scope>request</managed-bean-scope>
     <managed-property>
       <property-name>inventoryService</property-name>
       <value>#{inventoryService}</value>
+    </managed-property>
+    <managed-property>
+      <property-name>treeState</property-name>
+      <value>#{treeState}</value>
     </managed-property>
   </managed-bean>