Author: vbaranov
Date: 2008-03-10 12:04:01 -0400 (Mon, 10 Mar 2008)
New Revision: 6653
Modified:
trunk/ui/tree/src/main/config/component/tree.xml
trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java
Log:
http://jira.jboss.com/jira/browse/RF-1629
Modified: trunk/ui/tree/src/main/config/component/tree.xml
===================================================================
--- trunk/ui/tree/src/main/config/component/tree.xml 2008-03-10 15:56:08 UTC (rev 6652)
+++ trunk/ui/tree/src/main/config/component/tree.xml 2008-03-10 16:04:01 UTC (rev 6653)
@@ -66,8 +66,13 @@
<name>rowKeyVar</name>
<classname>java.lang.String</classname>
<description>The attribute provides access to a row key in a Request
scope</description>
- </property>
+ </property>
<property>
+ <name>treeNodeVar</name>
+ <classname>java.lang.String</classname>
+ <description>The attribute provides access to a TreeNode instance in a Request
scope</description>
+ </property>
+ <property>
<name>componentState</name>
<classname>org.ajax4jsf.model.DataComponentState</classname>
<description>It defines EL-binding for a component state for saving or
redefinition</description>
Modified: trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java
===================================================================
--- trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java 2008-03-10 15:56:08
UTC (rev 6652)
+++ trunk/ui/tree/src/main/java/org/richfaces/component/UITree.java 2008-03-10 16:04:01
UTC (rev 6653)
@@ -35,6 +35,7 @@
import javax.faces.event.FacesEvent;
import javax.faces.event.FacesListener;
import javax.faces.event.PhaseId;
+import javax.faces.model.DataModel;
import org.ajax4jsf.component.AjaxComponent;
import org.ajax4jsf.component.UIDataAdaptor;
@@ -111,6 +112,13 @@
public final static String DEFAULT_HIGHLIGHTED_CSS_CLASS = "dr-tree-i-hl";
private UITreeNode defaultFacet;
+
+ /**
+ * Name of EL variable for the tree node.
+ * This reference is needed to let this parent class
+ * know about the attributes defined in the subclass
+ */
+ private String _treeNodeVar;
public UITree() {
super();
@@ -124,6 +132,24 @@
}
/**
+ * Get name of EL variable for the tree node.
+ *
+ * @return the varState
+ */
+ public String getTreeNodeVar() {
+ return _treeNodeVar;
+ }
+
+ /**
+ * Set the name of EL variable
+ *
+ * @param treeNodeVar the varStatus to set
+ */
+ public void setTreeNodeVar(String treeNodeVar) {
+ this._treeNodeVar = treeNodeVar;
+ }
+
+ /**
* Lazily creates default node representation that is used if there is no
* {@link UITreeNode} child for that nodeFace
*
@@ -276,6 +302,34 @@
return getOrCreateDefaultFacet();
}
+
+ /**
+ * Setup EL variable for different iteration. Value of row tree node
+ * is put into request scope attributes with name "treeNodeVar" bean
+ * property. All other attributes are processed in parent
+ * <code>UIDataAdaptor</code> class
+ *
+ * @param faces - current faces context
+ * @param localModel - reference to data model
+ * @param rowSelected - boolean flag indicating whether the row is selected
+ */
+ protected void setupVariable(FacesContext faces, DataModel localModel, boolean
rowSelected) {
+ super.setupVariable(faces, localModel, rowSelected);
+ // get the map storing the request scope attributes
+ Map<String, Object> attrs = faces.getExternalContext().getRequestMap();
+
+ String treeNodeVar = getTreeNodeVar();
+ if (rowSelected) {
+ // Current row tree node.
+ if (treeNodeVar != null) {
+ attrs.put(treeNodeVar, getTreeNode());
+ }
+ } else {
+ if (treeNodeVar != null) {
+ attrs.remove(treeNodeVar);
+ }
+ }
+ }
/*
* (non-Javadoc)