You are viewing a plain text version of this content. The canonical link for it is here.
Posted to adffaces-commits@incubator.apache.org by aw...@apache.org on 2007/04/15 22:43:52 UTC

svn commit: r529084 - in /incubator/adffaces/trunk/trinidad/trinidad-demo/src/main: java/org/apache/myfaces/trinidaddemo/PartialDemoUtilBean.java webapp/demos/pprDemos.jspx

Author: awiner
Date: Sun Apr 15 15:43:49 2007
New Revision: 529084

URL: http://svn.apache.org/viewvc?view=rev&rev=529084
Log:
ADFFACES-434: Dynamic View Handeling from a ValueChangeEvent(SelectOneChoice or Similar)
- Check in demo showing this is working

Modified:
    incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PartialDemoUtilBean.java
    incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/demos/pprDemos.jspx

Modified: incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PartialDemoUtilBean.java
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PartialDemoUtilBean.java?view=diff&rev=529084&r1=529083&r2=529084
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PartialDemoUtilBean.java (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/PartialDemoUtilBean.java Sun Apr 15 15:43:49 2007
@@ -18,7 +18,10 @@
  */
 package org.apache.myfaces.trinidaddemo;
 
+import javax.faces.application.ViewHandler;
 import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
+import javax.faces.context.FacesContext;
 import javax.faces.event.ActionEvent;
 import javax.faces.event.ValueChangeEvent;
 
@@ -104,6 +107,18 @@
   public void setStatus(PartialDemoStatusBean status)
   {
     _status = status;
+  }
+
+  public void navigate(ValueChangeEvent vce)
+  {
+    Object newValue = vce.getNewValue();
+    if ((newValue != null) && !"".equals(newValue))
+    {
+      FacesContext fContext = FacesContext.getCurrentInstance(); 
+      ViewHandler vh = fContext.getApplication().getViewHandler(); 
+      UIViewRoot root = vh.createView(fContext, newValue.toString()); 
+      fContext.setViewRoot(root); 
+    }
   }
 
   private void _resetList()

Modified: incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/demos/pprDemos.jspx
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/demos/pprDemos.jspx?view=diff&rev=529084&r1=529083&r2=529084
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/demos/pprDemos.jspx (original)
+++ incubator/adffaces/trunk/trinidad/trinidad-demo/src/main/webapp/demos/pprDemos.jspx Sun Apr 15 15:43:49 2007
@@ -278,6 +278,15 @@
          <tr:resetActionListener/>
         </tr:commandButton>
        </tr:panelHeader>
+       <tr:panelHeader text="Changing the value of this selectOneChoice will navigate to another page.">
+         <tr:selectOneChoice autoSubmit="true"
+                             label="Navigate"
+                             unselectedLabel="Nowhere"
+                             valueChangeListener="#{partialDemoUtil.navigate}">
+          <tr:selectItem label="Index" value="/index.jspx"/>
+          <tr:selectItem label="Component Demos" value="/componentDemos.jspx"/>
+         </tr:selectOneChoice>
+       </tr:panelHeader>
       </tr:panelGroupLayout>
      </tr:panelHeader>
      </tr:panelPage>