[richfaces-svn-commits] JBoss Rich Faces SVN: r2919 - in trunk/samples/richfaces-demo/src/main: webapp/WEB-INF and 2 other directories.
richfaces-svn-commits at lists.jboss.org
richfaces-svn-commits at lists.jboss.org
Wed Sep 12 18:04:35 EDT 2007
Author: nbelaevski
Date: 2007-09-12 18:04:35 -0400 (Wed, 12 Sep 2007)
New Revision: 2919
Added:
trunk/samples/richfaces-demo/src/main/java/org/richfaces/treemodeladaptor/PostbackPhaseListener.java
trunk/samples/richfaces-demo/src/main/java/org/richfaces/treemodeladaptor/TreeDemoStateAdvisor.java
Modified:
trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/treeNodesAdaptor/examples/recursiveAdaptor.xhtml
trunk/samples/richfaces-demo/src/main/webapp/richfaces/treeNodesAdaptor/usage.xhtml
Log:
Tree model adaptor demo updated
Added: trunk/samples/richfaces-demo/src/main/java/org/richfaces/treemodeladaptor/PostbackPhaseListener.java
===================================================================
--- trunk/samples/richfaces-demo/src/main/java/org/richfaces/treemodeladaptor/PostbackPhaseListener.java (rev 0)
+++ trunk/samples/richfaces-demo/src/main/java/org/richfaces/treemodeladaptor/PostbackPhaseListener.java 2007-09-12 22:04:35 UTC (rev 2919)
@@ -0,0 +1,41 @@
+package org.richfaces.treemodeladaptor;
+
+import java.util.Map;
+
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.event.PhaseEvent;
+import javax.faces.event.PhaseId;
+import javax.faces.event.PhaseListener;
+
+public class PostbackPhaseListener implements PhaseListener {
+
+ public static final String POSTBACK_ATTRIBUTE_NAME = PostbackPhaseListener.class.getName();
+
+ public void afterPhase(PhaseEvent event) {
+ }
+
+ public void beforePhase(PhaseEvent event) {
+ FacesContext facesContext = event.getFacesContext();
+ Map requestMap = facesContext.getExternalContext().getRequestMap();
+ requestMap.put(POSTBACK_ATTRIBUTE_NAME, Boolean.TRUE);
+ }
+
+ public PhaseId getPhaseId() {
+ return PhaseId.APPLY_REQUEST_VALUES;
+ }
+
+ public static boolean isPostback() {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if (facesContext != null) {
+ ExternalContext externalContext = facesContext.getExternalContext();
+ if (externalContext != null) {
+ return Boolean.TRUE.equals(
+ externalContext.getRequestMap().get(POSTBACK_ATTRIBUTE_NAME));
+ }
+ }
+
+ return false;
+ }
+
+}
Added: trunk/samples/richfaces-demo/src/main/java/org/richfaces/treemodeladaptor/TreeDemoStateAdvisor.java
===================================================================
--- trunk/samples/richfaces-demo/src/main/java/org/richfaces/treemodeladaptor/TreeDemoStateAdvisor.java (rev 0)
+++ trunk/samples/richfaces-demo/src/main/java/org/richfaces/treemodeladaptor/TreeDemoStateAdvisor.java 2007-09-12 22:04:35 UTC (rev 2919)
@@ -0,0 +1,25 @@
+package org.richfaces.treemodeladaptor;
+
+import org.richfaces.component.UITree;
+import org.richfaces.component.state.TreeStateAdvisor;
+import org.richfaces.model.TreeRowKey;
+
+public class TreeDemoStateAdvisor implements TreeStateAdvisor {
+
+ public Boolean adviseNodeOpened(UITree tree) {
+ if (!PostbackPhaseListener.isPostback()) {
+ Object key = tree.getRowKey();
+ TreeRowKey treeRowKey = (TreeRowKey) key;
+ if (treeRowKey == null || treeRowKey.depth() <= 2) {
+ return Boolean.TRUE;
+ }
+ }
+
+ return null;
+ }
+
+ public Boolean adviseNodeSelected(UITree tree) {
+ return null;
+ }
+
+}
Modified: trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml 2007-09-12 21:57:32 UTC (rev 2918)
+++ trunk/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml 2007-09-12 22:04:35 UTC (rev 2919)
@@ -158,8 +158,13 @@
<property-class>java.lang.String</property-class>
<value>Paint 2D</value>
</managed-property>
- </managed-bean>
+ </managed-bean>
<managed-bean>
+ <managed-bean-name>treeDemoStateAdvisor</managed-bean-name>
+ <managed-bean-class>org.richfaces.treemodeladaptor.TreeDemoStateAdvisor</managed-bean-class>
+ <managed-bean-scope>application</managed-bean-scope>
+ </managed-bean>
+ <managed-bean>
<managed-bean-name>fileSystemBean</managed-bean-name>
<managed-bean-class>org.richfaces.treemodeladaptor.FileSystemBean</managed-bean-class>
<managed-bean-scope>application</managed-bean-scope>
@@ -278,5 +283,8 @@
<from-outcome>previous</from-outcome>
<to-view-id>/richfaces/include/examples/wstep2.xhtml</to-view-id>
</navigation-case>
- </navigation-rule>
+ </navigation-rule>
+ <lifecycle>
+ <phase-listener>org.richfaces.treemodeladaptor.PostbackPhaseListener</phase-listener>
+ </lifecycle>
</faces-config>
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/treeNodesAdaptor/examples/recursiveAdaptor.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/treeNodesAdaptor/examples/recursiveAdaptor.xhtml 2007-09-12 21:57:32 UTC (rev 2918)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/treeNodesAdaptor/examples/recursiveAdaptor.xhtml 2007-09-12 22:04:35 UTC (rev 2919)
@@ -5,10 +5,12 @@
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
+ <rich:separator height="1" style="padding:10px 0" />
<h:form>
- <rich:tree style="width:300px" switchType="ajax">
+ <rich:tree style="width:300px" switchType="ajax" stateAdvisor="#{treeDemoStateAdvisor}">
<rich:recursiveTreeNodesAdaptor roots="#{fileSystemBean.sourceRoots}" var="item" nodes="#{item.nodes}" />
</rich:tree>
</h:form>
+ <rich:separator height="1" style="padding:10px 0" />
</ui:composition>
\ No newline at end of file
Modified: trunk/samples/richfaces-demo/src/main/webapp/richfaces/treeNodesAdaptor/usage.xhtml
===================================================================
--- trunk/samples/richfaces-demo/src/main/webapp/richfaces/treeNodesAdaptor/usage.xhtml 2007-09-12 21:57:32 UTC (rev 2918)
+++ trunk/samples/richfaces-demo/src/main/webapp/richfaces/treeNodesAdaptor/usage.xhtml 2007-09-12 22:04:35 UTC (rev 2919)
@@ -36,6 +36,16 @@
<ui:param name="openlabel" value="View FileSystemNode.java Source" />
<ui:param name="sourcetype" value="java" />
</ui:include>
+ <ui:include src="/templates/include/sourceview.xhtml">
+ <ui:param name="sourcepath" value="/WEB-INF/src/org/richfaces/treemodeladaptor/PostbackPhaseListener.java"/>
+ <ui:param name="openlabel" value="View PostbackPhaseListener.java Source" />
+ <ui:param name="sourcetype" value="java" />
+ </ui:include>
+ <ui:include src="/templates/include/sourceview.xhtml">
+ <ui:param name="sourcepath" value="/WEB-INF/src/org/richfaces/treemodeladaptor/TreeDemoStateAdvisor.java"/>
+ <ui:param name="openlabel" value="View TreeDemoStateAdvisor.java Source" />
+ <ui:param name="sourcetype" value="java" />
+ </ui:include>
</div>
</h:panelGroup>
<f:verbatim rendered="#{empty fileSystemBean.sourceRoots}">
More information about the richfaces-svn-commits
mailing list