Author: lfryc(a)redhat.com
Date: 2010-12-15 12:09:25 -0500 (Wed, 15 Dec 2010)
New Revision: 20585
Added:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichTreeListenerBean.java
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richTree/simple.xhtml
modules/tests/metamer/trunk/application/src/main/webapp/components/richTree/treeAdaptors.xhtml
Log:
rich:tree - added server-side listeners (RF-9717) sample (RF-9827)
Added:
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichTreeListenerBean.java
===================================================================
---
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichTreeListenerBean.java
(rev 0)
+++
modules/tests/metamer/trunk/application/src/main/java/org/richfaces/tests/metamer/bean/RichTreeListenerBean.java 2010-12-15
17:09:25 UTC (rev 20585)
@@ -0,0 +1,58 @@
+/*******************************************************************************
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc. and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ *******************************************************************************/
+package org.richfaces.tests.metamer.bean;
+
+import javax.faces.bean.ManagedBean;
+import javax.faces.bean.RequestScoped;
+
+import org.richfaces.event.TreeSelectionChangeEvent;
+import org.richfaces.event.TreeToggleEvent;
+
+/**
+ * @author <a href="mailto:lfryc@redhat.com">Lukas Fryc</a>
+ * @version $Revision$
+ */
+@ManagedBean(name = "richTreeListenerBean")
+@RequestScoped
+public class RichTreeListenerBean {
+
+ private TreeSelectionChangeEvent treeSelectionChangeEvent;
+ private TreeToggleEvent treeToggleEvent;
+
+ public void processSelectionChange(TreeSelectionChangeEvent event) {
+ this.treeSelectionChangeEvent = event;
+ RichBean.logToPage("* selection change listener invoked");
+ }
+
+ public void processToggle(TreeToggleEvent event) {
+ this.treeToggleEvent = event;
+ RichBean.logToPage("* tree toggle listener invoked");
+ }
+
+ public TreeSelectionChangeEvent getTreeSelectionChangeEvent() {
+ return treeSelectionChangeEvent;
+ }
+
+ public TreeToggleEvent getTreeToggleEvent() {
+ return treeToggleEvent;
+ }
+}
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richTree/simple.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richTree/simple.xhtml 2010-12-15
17:08:39 UTC (rev 20584)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richTree/simple.xhtml 2010-12-15
17:09:25 UTC (rev 20585)
@@ -2,7 +2,7 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:metamer="http://java.sun.com/jsf/composite/metamer"
-
xmlns:rich="http://richfaces.org/rich">
+
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j">
<!--
JBoss, Home of Professional Open Source
@@ -80,6 +80,8 @@
iconClass="#{richTreeBean.attributes['iconClass'].value}"
labelClass="#{richTreeBean.attributes['labelClass'].value}"
nodeClass="#{richTreeBean.attributes['nodeClass'].value}"
+
selectionChangeListener="#{richTreeListenerBean.processSelectionChange}"
+ toggleListener="#{richTreeListenerBean.processToggle}"
<rich:treeNode type="country"
@@ -126,6 +128,37 @@
</ui:define>
<ui:define name="outOfTemplateAfter">
+ <a4j:outputPanel ajaxRendered="true">
+ <h:panelGrid id="selectionOutput" columns="2">
+ <h:outputLabel value="Selection:" />
+ <h:outputText value="#{richTreeBean.selection}" />
+
+ <h:outputLabel value="Selection Change Event:"
rendered="#{not empty richTreeListenerBean.treeSelectionChangeEvent}" />
+ <h:panelGrid columns="2" rendered="#{not empty
richTreeListenerBean.treeSelectionChangeEvent}">
+ <h:outputLabel value="Client ID:" />
+ <h:outputText
value="#{richTreeListenerBean.treeSelectionChangeEvent.component.id}" />
+
+ <h:outputLabel value="New Selection:" />
+ <h:outputText
value="#{richTreeListenerBean.treeSelectionChangeEvent.newSelection}" />
+
+ <h:outputLabel value="Old Selection:" />
+ <h:outputText
value="#{richTreeListenerBean.treeSelectionChangeEvent.oldSelection}" />
+ </h:panelGrid>
+
+ <h:outputLabel value="Tree Toggle Event:" rendered="#{not
empty richTreeListenerBean.treeToggleEvent}" />
+ <h:panelGrid columns="2" rendered="#{not empty
richTreeListenerBean.treeToggleEvent}">
+ <h:outputLabel value="Client ID:" />
+ <h:outputText
value="#{richTreeListenerBean.treeToggleEvent.component.id}" />
+
+ <h:outputLabel value="Collapsed:" />
+ <h:outputText
value="#{richTreeListenerBean.treeToggleEvent.collapsed}" />
+
+ <h:outputLabel value="Expanded:" />
+ <h:outputText
value="#{richTreeListenerBean.treeToggleEvent.expanded}" />
+ </h:panelGrid>
+ </h:panelGrid>
+ </a4j:outputPanel>
+
<fieldset>
<legend>rich:tree</legend>
<metamer:attributes value="#{richTreeBean.attributes}"
id="attributes" />
Modified:
modules/tests/metamer/trunk/application/src/main/webapp/components/richTree/treeAdaptors.xhtml
===================================================================
---
modules/tests/metamer/trunk/application/src/main/webapp/components/richTree/treeAdaptors.xhtml 2010-12-15
17:08:39 UTC (rev 20584)
+++
modules/tests/metamer/trunk/application/src/main/webapp/components/richTree/treeAdaptors.xhtml 2010-12-15
17:09:25 UTC (rev 20585)
@@ -78,12 +78,10 @@
iconClass="#{richTreeBean.attributes['iconClass'].value}"
labelClass="#{richTreeBean.attributes['labelClass'].value}"
nodeClass="#{richTreeBean.attributes['nodeClass'].value}"
- >
-
- <a4j:ajax event="selectionchange"
render="selectionOutput" />
- <a4j:ajax event="nodetoggle"
render="selectionOutput" />
+
selectionChangeListener="#{richTreeListenerBean.processSelectionChange}"
+ toggleListener="#{richTreeListenerBean.processToggle}">
+ >
-
<rich:treeModelRecursiveAdaptor
roots="#{richTreeModelRecursiveAdaptorBean.rootNodes}"
nodes="#{richTreeModelRecursiveAdaptorBean.useMapModel ?
node.recursiveMap : node.recursiveList}"
@@ -146,29 +144,52 @@
<ui:define name="outOfTemplateAfter">
- <h:panelGrid id="selectionOutput" columns="2">
- <h:outputLabel value="Selection:" />
- <h:outputText value="#{richTreeBean.selection}" />
-
- <h:outputLabel value="Lazy Initialized:" />
- <h:outputText
value="#{richTreeModelRecursiveAdaptorBean.lazyInitializedNodes}" />
-
- <h:outputLabel value="Recursive Leaf Children Nullable:" />
- <h:selectBooleanCheckbox
value="#{richTreeModelRecursiveAdaptorBean.leafChildrenNullable}">
- <a4j:ajax render="commonGrid" />
- </h:selectBooleanCheckbox>
-
- <h:outputLabel value="Recursive Model Representation:" />
- <h:selectOneRadio
value="#{richTreeModelRecursiveAdaptorBean.useMapModel}">
- <f:selectItem itemLabel="List<RecursiveNode>"
itemValue="false" />
- <f:selectItem itemLabel="Map<Integer,
RecursiveNode>" itemValue="true" />
-
- <a4j:ajax render="commonGrid" />
- </h:selectOneRadio>
- </h:panelGrid>
-
- <a4j:outputPanel>
-
+ <a4j:outputPanel ajaxRendered="true">
+ <h:panelGrid id="selectionOutput" columns="2">
+
+ <h:outputLabel value="Recursive Leaf Children Nullable:" />
+ <h:selectBooleanCheckbox
value="#{richTreeModelRecursiveAdaptorBean.leafChildrenNullable}">
+ <a4j:ajax render="commonGrid" />
+ </h:selectBooleanCheckbox>
+
+ <h:outputLabel value="Recursive Model Representation:" />
+ <h:selectOneRadio
value="#{richTreeModelRecursiveAdaptorBean.useMapModel}">
+ <f:selectItem itemLabel="List<RecursiveNode>"
itemValue="false" />
+ <f:selectItem itemLabel="Map<Integer,
RecursiveNode>" itemValue="true" />
+
+ <a4j:ajax render="commonGrid" />
+ </h:selectOneRadio>
+
+ <h:outputLabel value="Selection:" />
+ <h:outputText value="#{richTreeBean.selection}" />
+
+ <h:outputLabel value="Lazy Initialized:" />
+ <h:outputText
value="#{richTreeModelRecursiveAdaptorBean.lazyInitializedNodes}" />
+
+ <h:outputLabel value="Selection Change Event:"
rendered="#{not empty richTreeListenerBean.treeSelectionChangeEvent}" />
+ <h:panelGrid columns="2" rendered="#{not empty
richTreeListenerBean.treeSelectionChangeEvent}">
+ <h:outputLabel value="Client ID:" />
+ <h:outputText
value="#{richTreeListenerBean.treeSelectionChangeEvent.component.id}" />
+
+ <h:outputLabel value="New Selection:" />
+ <h:outputText
value="#{richTreeListenerBean.treeSelectionChangeEvent.newSelection}" />
+
+ <h:outputLabel value="Old Selection:" />
+ <h:outputText
value="#{richTreeListenerBean.treeSelectionChangeEvent.oldSelection}" />
+ </h:panelGrid>
+
+ <h:outputLabel value="Tree Toggle Event:" rendered="#{not
empty richTreeListenerBean.treeToggleEvent}" />
+ <h:panelGrid columns="2" rendered="#{not empty
richTreeListenerBean.treeToggleEvent}">
+ <h:outputLabel value="Client ID:" />
+ <h:outputText
value="#{richTreeListenerBean.treeToggleEvent.component.id}" />
+
+ <h:outputLabel value="Collapsed:" />
+ <h:outputText
value="#{richTreeListenerBean.treeToggleEvent.collapsed}" />
+
+ <h:outputLabel value="Expanded:" />
+ <h:outputText
value="#{richTreeListenerBean.treeToggleEvent.expanded}" />
+ </h:panelGrid>
+ </h:panelGrid>
</a4j:outputPanel>
<fieldset>