Author: nbelaevski
Date: 2007-03-22 20:01:13 -0400 (Thu, 22 Mar 2007)
New Revision: 123
Modified:
trunk/richfaces-samples/tree-demo/src/main/java/org/richfaces/Bean.java
trunk/richfaces-samples/tree-demo/src/main/resources/org/richfaces/test.xml
trunk/richfaces-samples/tree-demo/src/main/webapp/pages/index.jsp
Log:
Test bean changed to use getTreeNode() method instead of lookup.
Manual node expansion test added
Modified: trunk/richfaces-samples/tree-demo/src/main/java/org/richfaces/Bean.java
===================================================================
--- trunk/richfaces-samples/tree-demo/src/main/java/org/richfaces/Bean.java 2007-03-22
23:59:20 UTC (rev 122)
+++ trunk/richfaces-samples/tree-demo/src/main/java/org/richfaces/Bean.java 2007-03-23
00:01:13 UTC (rev 123)
@@ -26,6 +26,7 @@
import java.util.LinkedHashMap;
import java.util.Map;
+import javax.faces.FacesException;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.event.FacesEvent;
@@ -60,8 +61,9 @@
private String iconExpanded = null;
private String iconLeaf = null;
private String icon = null;
-
+ private String pathToExpand;
+
public String getIcon() {
return icon;
}
@@ -111,7 +113,8 @@
} catch (IOException e) {
e.printStackTrace();
}
- findNode(null);
+
+ initData();
}
public TreeNode getData() {
@@ -148,23 +151,12 @@
public void onSelect(NodeSelectedEvent event) {
System.out.println("Node selected: " + getTree(event).getRowKey());
- if (getTree(event).getRowKey()!=null) {
- findNode(((TreeRowKey) getTree(event).getRowKey()).iterator());
+ if (getTree(event).getTreeNode()!=null) {
+ selectedNode = getTree(event).getTreeNode();
+ initData();
}
}
- private void findNode(Iterator iterator) {
- selectedNode = data;
- if (iterator != null) {
- while (iterator.hasNext()) {
- selectedNode = selectedNode.getChild(iterator.next());
-
- }
- }
- initData();
-
- }
-
private void initData() {
selectedNodeChildren.clear();
if (selectedNode != null) {
@@ -275,5 +267,25 @@
public void setIconLeaf(String iconLeaf) {
this.iconLeaf = iconLeaf;
}
+
+ public String getPathToExpand() {
+ return pathToExpand;
+ }
+
+ public void setPathToExpand(String pathToExpand) {
+ this.pathToExpand = pathToExpand;
+ }
+ public String expandNode() {
+ String pathToExpand = getPathToExpand();
+ if (pathToExpand != null && pathToExpand.trim().length() != 0) {
+ try {
+ ((UITree) getTree()).queueNodeExpand(new ListRowKey(pathToExpand));
+ } catch (IOException e) {
+ throw new FacesException(e);
+ }
+ }
+
+ return null;
+ }
}
\ No newline at end of file
Modified: trunk/richfaces-samples/tree-demo/src/main/resources/org/richfaces/test.xml
===================================================================
--- trunk/richfaces-samples/tree-demo/src/main/resources/org/richfaces/test.xml 2007-03-22
23:59:20 UTC (rev 122)
+++ trunk/richfaces-samples/tree-demo/src/main/resources/org/richfaces/test.xml 2007-03-23
00:01:13 UTC (rev 123)
@@ -1,5 +1,5 @@
<?xml version="1.0"?>
-<web-app version="2.4" id="webApp:id">
+<web-app version="2.4" id="webApp:id_1">
<description>Tree demo</description>
<display-name>tree-demo</display-name>
<context-param>
Modified: trunk/richfaces-samples/tree-demo/src/main/webapp/pages/index.jsp
===================================================================
--- trunk/richfaces-samples/tree-demo/src/main/webapp/pages/index.jsp 2007-03-22 23:59:20
UTC (rev 122)
+++ trunk/richfaces-samples/tree-demo/src/main/webapp/pages/index.jsp 2007-03-23 00:01:13
UTC (rev 123)
@@ -56,7 +56,7 @@
onexpand="window.status='expandedNode: '+event.expandedNode"
oncollapse="window.status='collapsedNode: '+event.collapsedNode"
ajaxSubmitSelection="true" reRender="outputText,
selectOneListbox"
- preserveModel="state"
+ preserveModel="none"
dragIndicator="treeIndicator"
acceptedTypes="file1"
@@ -84,10 +84,17 @@
</rich:treeNode>
</rich:tree>
+ <h:outputText value="Enter path to expand, eg. [webApp_:id__1 ,
webApp_:id__1:7 ]:" />
+ <h:inputText value="#{bean.pathToExpand}">
+ <a4j:support event="onchange" reRender="tree"
action="#{bean.expandNode}"/>
+ </h:inputText>
+
</h:form>
<a4j:status startText="...start..." />
+ <a4j:log hotkey="O" />
+
</f:view>
</body>
</html>
Show replies by date