myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ckor...@apache.org
Subject svn commit: r929577 - in /myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main: java/org/apache/myfaces/trinidaddemo/components/navigation/train/ webapp/WEB-INF/
Date Wed, 31 Mar 2010 15:10:07 GMT
Author: ckormos
Date: Wed Mar 31 15:10:07 2010
New Revision: 929577

URL: http://svn.apache.org/viewvc?rev=929577&view=rev
Log:
fixed existing train demo variant, added new variant with MaxVisited.

Modified:
    myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/components/navigation/train/TrainBean.java
    myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/components/navigation/train/TrainDemo.java
    myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/webapp/WEB-INF/faces-config.xml

Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/components/navigation/train/TrainBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/components/navigation/train/TrainBean.java?rev=929577&r1=929576&r2=929577&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/components/navigation/train/TrainBean.java
(original)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/components/navigation/train/TrainBean.java
Wed Mar 31 15:10:07 2010
@@ -21,85 +21,46 @@ package org.apache.myfaces.trinidaddemo.
 import org.apache.myfaces.trinidad.model.ChildPropertyTreeModel;
 import org.apache.myfaces.trinidad.model.ProcessMenuModel;
 import org.apache.myfaces.trinidaddemo.NavigationHandlerBean;
-import org.apache.myfaces.trinidaddemo.support.jsf.JsfHelper;
 
-import java.beans.IntrospectionException;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
 import java.util.ArrayList;
-import java.util.List;
+import java.io.Serializable;
 
 /**
  *
  */
 public class TrainBean extends ProcessMenuModel /*implements java.io.Serializable*/ {
-    private ArrayList<TrainNavigationItem> arrayList = new ArrayList<TrainNavigationItem>();
-    private NavigationHandlerBean navigationHandler = (NavigationHandlerBean) JsfHelper.getBean("navigationHandler");
-
 
     public TrainBean() {
-        super();
-        addList();      
-    }
-
-    public TrainBean(Object instance, String viewIdProperty) throws IntrospectionException
{
-        super(instance, viewIdProperty);
-        addList();
-    }
 
-    public TrainBean(Object instance, String viewIdProperty, String maxPathKey) throws IntrospectionException
{
-        super(instance, viewIdProperty);
-        setMaxPathKey(maxPathKey);
-        addList();
-    }
+        ArrayList<TrainNavigationItem> arrayList = new ArrayList<TrainNavigationItem>();
 
-    public void addList() {
-        TrainNavigationItem page1 = new TrainNavigationItem("1.  General info", "trainGeneralInfo");
-        page1.setViewId("/components/navigation/train/generalInfo.xhtml");
-        TrainNavigationItem page2 = new TrainNavigationItem("2.  Company info", "trainCompanyInfo");
-        page2.setViewId("/components/navigation/train/companyInfo.xhtml");
-        TrainNavigationItem page3 = new TrainNavigationItem("3.  JSF survey", "trainJsfSurvey");
-        page3.setViewId("/components/navigation/train/jsfSurvey.xhtml");
-        TrainNavigationItem page4 = new TrainNavigationItem("4.  Trinidad survey", "trainTrinidadSurvey");
-        page4.setViewId("/components/navigation/train/trinidadSurvey.xhtml");
-        TrainNavigationItem page5 = new TrainNavigationItem("5.  You are done!", "trainYouAreDone");
-        page5.setViewId("/components/navigation/train/youAreDone.xhtml");
-
-        arrayList.add(page1);
-        arrayList.add(page2);
-        arrayList.add(page3);
-        arrayList.add(page4);
-        arrayList.add(page5);
+        arrayList.add(new TrainNavigationItem("1.  General info", "trainGeneralInfo", "/components/navigation/train/generalInfo.xhtml"));
+        arrayList.add(new TrainNavigationItem("2.  Company info", "trainCompanyInfo", "/components/navigation/train/companyInfo.xhtml"));
+        arrayList.add(new TrainNavigationItem("3.  JSF survey", "trainJsfSurvey", "/components/navigation/train/jsfSurvey.xhtml"));
+        arrayList.add(new TrainNavigationItem("4.  Trinidad survey", "trainTrinidadSurvey",
"/components/navigation/train/trinidadSurvey.xhtml"));
+        arrayList.add(new TrainNavigationItem("5.  You are done!", "trainYouAreDone", "/components/navigation/train/youAreDone.xhtml"));
 
         setViewIdProperty("viewId");
 
-        ChildPropertyTreeModel childProperty = new ChildPropertyTreeModel();
-        childProperty.setChildProperty("children");
-        childProperty.setWrappedData(arrayList);
-
-        this.setWrappedData(childProperty);
-    }
+        FacesContext fc = FacesContext.getCurrentInstance();
+        NavigationHandlerBean navigationHandler = (NavigationHandlerBean) FacesContext.getCurrentInstance().getApplication().getELResolver().getValue(fc.getELContext(),
null, "navigationHandler");
 
-    public ArrayList<TrainNavigationItem> getArrayList() {
-        return arrayList;
-    }
-
-
-    public static class TrainNavigationItem implements java.io.Serializable {
+        if (TrainDemo.VARIANTS.MaxVisited == navigationHandler.getCurrentComponentVariantDemo().getVariantId())
{
+            setMaxPathKey("TRAIN_DEMO_MAX_PATH_KEY");
+        }
         
-        private static final long serialVersionUID = 375702448013892058L;
-
-        private String _label = null;
-        private String _viewId = null;
-        private String _destination = null;
-        private List<?> _children = null;
-        private String _outcome = null;
+        setWrappedData(new ChildPropertyTreeModel(arrayList,null));
+    }
 
 
-        public TrainNavigationItem() {
-        }
+    public class TrainNavigationItem implements Serializable {
 
-        public TrainNavigationItem(String _label, String _outcome) {
+        public TrainNavigationItem(String _label, String _outcome, String _viewId) {
             setLabel(_label);
             setOutcome(_outcome);
+            setViewId (_viewId);
         }
 
         public void setLabel(String label) {
@@ -126,21 +87,10 @@ public class TrainBean extends ProcessMe
             return _viewId;
         }
 
-        public void setDestination(String destination) {
-            _destination = destination;
-        }
-
-        public String getDestination() {
-            return _destination;
-        }
-
-        public List<?> getChildren() {
-            return _children;
-        }
-
-        public void setChildren(List<?> children) {
-            _children = children;
-        }
 
+        private String _viewId = null;
+        private String _label = null;
+        private String _outcome = null;
+        private static final long serialVersionUID = 375702448013892058L;
     }
 }

Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/components/navigation/train/TrainDemo.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/components/navigation/train/TrainDemo.java?rev=929577&r1=929576&r2=929577&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/components/navigation/train/TrainDemo.java
(original)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/java/org/apache/myfaces/trinidaddemo/components/navigation/train/TrainDemo.java
Wed Mar 31 15:10:07 2010
@@ -30,6 +30,11 @@ public class TrainDemo extends AbstractC
 
     private static final long serialVersionUID = -1982060956387098910L;
 
+    static enum VARIANTS implements IComponentDemoVariantId {
+		PlusOne,
+        MaxVisited
+	}
+
 	/**
 	 * Constructor.
 	 */
@@ -42,6 +47,24 @@ public class TrainDemo extends AbstractC
                 "/components/navigation/train/trinidadSurvey.xhtml",
                 "/components/navigation/train/youAreDone.xhtml"
             });
+        
+        addComponentDemoVariant(new ComponentVariantDemoImpl(VARIANTS.PlusOne, "Plus One",
this,
+                new String[]{
+                    "/components/navigation/train/generalInfo.xhtml",
+                    "/components/navigation/train/companyInfo.xhtml",
+                    "/components/navigation/train/jsfSurvey.xhtml",
+                    "/components/navigation/train/trinidadSurvey.xhtml",
+                    "/components/navigation/train/youAreDone.xhtml"
+                }, getSummaryResourcePath(), getBackingBeanResourcePath()));
+
+        addComponentDemoVariant(new ComponentVariantDemoImpl(VARIANTS.MaxVisited, "Max Visited",
this,
+                new String[]{
+                    "/components/navigation/train/generalInfo.xhtml",
+                    "/components/navigation/train/companyInfo.xhtml",
+                    "/components/navigation/train/jsfSurvey.xhtml",
+                    "/components/navigation/train/trinidadSurvey.xhtml",
+                    "/components/navigation/train/youAreDone.xhtml"
+                }, getSummaryResourcePath(), getBackingBeanResourcePath()));
 	}
 
     public String getSummaryResourcePath() {

Modified: myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/webapp/WEB-INF/faces-config.xml?rev=929577&r1=929576&r2=929577&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/webapp/WEB-INF/faces-config.xml
(original)
+++ myfaces/trinidad/trunk/trinidad-examples/trinidad-components-showcase/src/main/webapp/WEB-INF/faces-config.xml
Wed Mar 31 15:10:07 2010
@@ -152,7 +152,7 @@
     <managed-bean>
         <managed-bean-name>trainBean</managed-bean-name>
         <managed-bean-class>org.apache.myfaces.trinidaddemo.components.navigation.train.TrainBean</managed-bean-class>
-        <managed-bean-scope>session</managed-bean-scope>
+        <managed-bean-scope>request</managed-bean-scope>
     </managed-bean>
 
     <managed-bean>
@@ -237,26 +237,31 @@
         <navigation-case>
             <from-outcome>trainGeneralInfo</from-outcome>
             <to-view-id>/components/navigation/train/generalInfo.xhtml</to-view-id>
+            <redirect/>
         </navigation-case>
 
         <navigation-case>
             <from-outcome>trainCompanyInfo</from-outcome>
             <to-view-id>/components/navigation/train/companyInfo.xhtml</to-view-id>
+            <redirect/>
         </navigation-case>
 
         <navigation-case>
             <from-outcome>trainJsfSurvey</from-outcome>
             <to-view-id>/components/navigation/train/jsfSurvey.xhtml</to-view-id>
+            <redirect/>
         </navigation-case>
 
         <navigation-case>
             <from-outcome>trainTrinidadSurvey</from-outcome>
             <to-view-id>/components/navigation/train/trinidadSurvey.xhtml</to-view-id>
+            <redirect/>
         </navigation-case>
 
         <navigation-case>
             <from-outcome>trainYouAreDone</from-outcome>
             <to-view-id>/components/navigation/train/youAreDone.xhtml</to-view-id>
+            <redirect/>
         </navigation-case>
 
         <navigation-case>



Mime
View raw message