You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beehive.apache.org by do...@apache.org on 2005/02/12 19:23:48 UTC
svn commit: r153525 [1/2] - in incubator/beehive/trunk/netui:
src/javascript/tagshtml/ test/webapps/drt/coreWeb/bugs/j290/
test/webapps/drt/coreWeb/tree/expand/ test/webapps/drt/testRecorder/config/
test/webapps/drt/testRecorder/tests/
Author: dolander
Date: Sat Feb 12 10:23:46 2005
New Revision: 153525
URL: http://svn.apache.org/viewcvs?view=rev&rev=153525
Log:
Jira #226 -- We now initialize the state of the tree nodes recieved through XmlHttpRequest
Added a tree BVT with runAtClient, expandOnServer and the children created in the onExpand() method
Added a repo for Jira #290
Added:
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/bugs/j290/
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/bugs/j290/Controller.jpf
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/bugs/j290/index.jsp
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/tests/TreeExpand.xml
Modified:
incubator/beehive/trunk/netui/src/javascript/tagshtml/netui-tree.js
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tree/expand/Controller.jpf
incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tree/expand/Test.jsp
incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
Modified: incubator/beehive/trunk/netui/src/javascript/tagshtml/netui-tree.js
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/src/javascript/tagshtml/netui-tree.js?view=diff&r1=153524&r2=153525
==============================================================================
--- incubator/beehive/trunk/netui/src/javascript/tagshtml/netui-tree.js (original)
+++ incubator/beehive/trunk/netui/src/javascript/tagshtml/netui-tree.js Sat Feb 12 10:23:46 2005
@@ -176,6 +176,7 @@
//alert(dumpNodes(dump,pElement,0));
}
}
+ netUI.netUITree.init();
}
}
}
Added: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/bugs/j290/Controller.jpf
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/bugs/j290/Controller.jpf?view=auto&rev=153525
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/bugs/j290/Controller.jpf (added)
+++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/bugs/j290/Controller.jpf Sat Feb 12 10:23:46 2005
@@ -0,0 +1,123 @@
+package bugs.j290;
+
+import org.apache.beehive.netui.pageflow.FormData;
+import org.apache.beehive.netui.pageflow.Forward;
+import org.apache.beehive.netui.pageflow.PageFlowController;
+import org.apache.beehive.netui.pageflow.annotations.Jpf;
+import java.util.Enumeration;
+
+
+import javax.servlet.http.HttpSession;
+import javax.servlet.ServletRequest;
+
+/**
+ * This is the default controller for a blank web application.
+ */
+@Jpf.Controller
+public class Controller extends PageFlowController
+{
+ private String _action;
+ private String _text;
+ public Bean hiddenBean;
+ public BeanTwo beanTwo;
+
+ public String getAction()
+ {
+ return _action;
+ }
+
+ public String getText()
+ {
+ return _text;
+ }
+
+ @Jpf.Action(
+ forwards = {
+ @Jpf.Forward(name = "index", path = "index.jsp")
+ }
+ )
+ protected Forward begin()
+ {
+ _action = "begin";
+ return new Forward("index");
+ }
+
+ @Jpf.Action(
+ forwards = { @Jpf.Forward(name = "index", navigateTo = Jpf.NavigateTo.currentPage)})
+ protected Forward post(Bean postForm)
+ {
+ _action = "post";
+ _text = postForm.getText();
+ postForm.setText("");
+ return new Forward("index");
+ }
+
+ @Jpf.Action(
+ useFormBean="hiddenBean",
+ forwards = { @Jpf.Forward(name = "index", navigateTo = Jpf.NavigateTo.currentPage)})
+ protected Forward post2(Bean postForm)
+ {
+ _action = "post2";
+ _text = postForm.getText();
+ return new Forward("index");
+ }
+
+ @Jpf.Action(
+ useFormBean="beanTwo",
+ forwards = { @Jpf.Forward(name = "index", navigateTo = Jpf.NavigateTo.currentPage)})
+ protected Forward post3(BeanTwo postForm)
+ {
+ _action = "post3";
+ _text = postForm.getText();
+ return new Forward("index");
+ }
+
+ /**
+ * Callback that is invoked when this controller instance is created.
+ */
+ protected void onCreate()
+ {
+ hiddenBean = new Bean();
+ hiddenBean.setText("hiddenBean Defined");
+
+ beanTwo = new BeanTwo();
+ beanTwo.setText("beanTwo Defined");
+ }
+
+ /**
+ * Callback that is invoked when this controller instance is destroyed.
+ */
+ protected void onDestroy(HttpSession session)
+ {
+ }
+
+ public static class Bean extends FormData
+ {
+ private String _text;
+
+ public String getText()
+ {
+ return _text;
+ }
+
+ public void setText(String value)
+ {
+ _text = value;
+ }
+ }
+
+ public static class BeanTwo extends FormData
+ {
+ private String _text;
+
+ public String getText()
+ {
+ return _text;
+ }
+
+ public void setText(String value)
+ {
+ _text = value;
+ }
+ }
+}
Added: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/bugs/j290/index.jsp
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/bugs/j290/index.jsp?view=auto&rev=153525
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/bugs/j290/index.jsp (added)
+++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/bugs/j290/index.jsp Sat Feb 12 10:23:46 2005
@@ -0,0 +1,44 @@
+<%@ page language="java" contentType="text/html;charset=UTF-8"%>
+<%@ taglib prefix="netui" uri="http://beehive.apache.org/netui/tags-html-1.0"%>
+
+<netui:html idScope="html">
+ <head>
+ <netui:base/>
+ </head>
+ <netui:body>
+ Action: <netui:span value="${pageFlow.action}" /><br>
+ Text: <netui:span value="${pageFlow.text}" />
+ <p style="color:green">In this test, we have three forms. The bug is
+ that if one form preceeds another form, and both call actions with
+ the same bean type, if the second form has a useFormBean attribute,
+ it is hidden by the fact that the first form was processed first.
+ The third form is also has a useFormBean, but a different bean.
+ The second and third forms should have values when the page is
+ first displayed.
+ </p>
+ <table width="100%">
+ <tr><td width="33%" valign="top">
+ <h4>Form Bound to Action</h4>
+ <p style="color:green">Form Bound to Action without useFormBean</p>
+ <netui:form tagId="f1" action="post">
+ Text: <netui:textBox dataSource="actionForm.text" />
+ <netui:button value="submit"/>
+ </netui:form>
+ </td><td width="33%" valign="top">
+ <h4>Form Bound to Action with useFormBean</h4>
+ <p style="color:green">Form Bound to Action with same form bean type, but using useFormBean. This should have a value when the page is first rendered.</p>
+ <netui:form tagId="f2" action="post2">
+ Text: <netui:textBox dataSource="pageFlow.text" />
+ <netui:button value="submit"/>
+ </netui:form>
+ </td><td width="33%" valign="top">
+ <h4>useFormBean With Different Bean type</h4>
+ <p style="color:green">This form is also bound using useFormBean, but to a different Bean type. This should have a value when the page is first rendered.</p>
+ <netui:form tagId="f3" action="post3">
+ Text: <netui:textBox dataSource="actionForm.text" />
+ <netui:button value="submit"/>
+ </netui:form>
+ </td></tr>
+ </table>
+ </netui:body>
+</netui:html>
Modified: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tree/expand/Controller.jpf
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tree/expand/Controller.jpf?view=diff&r1=153524&r2=153525
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tree/expand/Controller.jpf (original)
+++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tree/expand/Controller.jpf Sat Feb 12 10:23:46 2005
@@ -1,104 +1,139 @@
package tree.expand;
-import org.apache.beehive.netui.pageflow.annotations.Jpf;
import org.apache.beehive.netui.pageflow.PageFlowController;
-import org.apache.beehive.netui.pageflow.Forward;
-import org.apache.beehive.netui.pageflow.requeststate.INameable;
-import org.apache.beehive.netui.pageflow.requeststate.NameService;
-import org.apache.beehive.netui.tags.tree.TreeElement;
+import org.apache.beehive.netui.pageflow.annotations.Jpf;
import org.apache.beehive.netui.tags.tree.ITreeRootElement;
+import org.apache.beehive.netui.tags.tree.TreeElement;
import org.apache.beehive.netui.tags.tree.TreeRenderState;
+import org.apache.beehive.netui.pageflow.requeststate.NameService;
import javax.servlet.ServletRequest;
-import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import org.apache.beehive.netui.pageflow.Forward;
-@Jpf.Controller ()
+@Jpf.Controller (
+ simpleActions = {
+ @Jpf.SimpleAction(name = "select", path = "Test.jsp")
+ }
+)
public class Controller extends PageFlowController
{
- private TreeElement root;
+ private TreeElement _root;
+ private int[] _children = {3,2,0,2,0,2,1,1,2};
+ private int _child = 0;
- public TreeElement getRoot ()
+ public TreeElement getRoot()
{
- return root;
+ return _root;
}
- @Jpf.Action
- (forwards = {
- @Jpf.Forward(name = "success",
- path = "begin.do")
- })
- public Forward select ()
+ @Jpf.Action(
+ forwards={
+ @Jpf.Forward(name="index", path="Test.jsp")
+ }
+ )
+ protected Forward begin()
{
- return new Forward ("success");
+ NameService ns = NameService.instance(getRequest().getSession());
+ ns.debugSetNameIntValue(6);
+ return new Forward("index");
}
- @Jpf.Action
- (forwards = {
- @Jpf.Forward(name = "success",
- path = "Test.jsp")
- })
- public Forward begin ()
+ @Jpf.Action(
+ forwards={
+ @Jpf.Forward(name="index", path="Test.jsp")
+ }
+ )
+ protected Forward reset()
{
- Forward f = new Forward ("success");
-
- root = new ToolTreeRootElement ("root", true);
- ToolTreeElement child1 = new ToolTreeElement ("child1", false);
- child1.setExpandOnServer(true);
- System.out.println("root.isLeaf() = " + root.isLeaf());
- root.addChild (child1);
+ _child = 0;
+ _root = new ToolTreeRootElement("0", false, getChildCount());
+ return new Forward("index");
+ }
- NameService ns = NameService.instance (getSession());
- ns.nameObject ("tree", (INameable) root);
- ns.put((INameable) root);
+ /**
+ * Callback that is invoked when this controller instance is created.
+ */
+ protected void onCreate()
+ {
+ _root = new ToolTreeRootElement("0", false, getChildCount());
+ }
- return f;
+ /**
+ * Callback that is invoked when this controller instance is destroyed.
+ */
+ protected void onDestroy(HttpSession session)
+ {
}
+ private int getChildCount()
+ {
+ if (_child == _children.length)
+ return 0;
+ return _children[_child++];
+ }
class ToolTreeElement extends TreeElement
{
- public ToolTreeElement (String s, boolean b)
+ private boolean _leaf;
+ private int _children;
+
+ public ToolTreeElement(String s, boolean b, int children)
{
- super (s, b);
- System.err.println("Here");
- this.setExpandOnServer (false);
- }
-
- public void onExpand (ServletRequest request)
- {
- System.err.println("Inside onExpand");
- if ( this.getLabel().equals ("child1"))
- {
- System.out.println ("creating child...");
- ToolTreeElement m =
- new ToolTreeElement ("foo", false);
- this.addChild (m);
- }
+ super(s, b);
+ _leaf = (children == 0);
+ _children = children;
+ setExpandOnServer(!_leaf);
}
- public boolean isLeaf ()
+ public void onExpand(ServletRequest request)
{
- if (this.getLabel().equals ("root") ||
- this.getLabel().equals ("child1"))
- {
- return false;
+ if (_children > 0 && size() == 0) {
+ for (int i=0;i<_children;i++) {
+ String name = getLabel() + "." + i;
+ ToolTreeElement m = new ToolTreeElement(name, false, getChildCount());
+ addChild(m);
+ }
}
- return true;
+ }
+
+ public boolean isLeaf()
+ {
+ return _leaf;
}
}
class ToolTreeRootElement extends ToolTreeElement implements ITreeRootElement
{
- String name = null;
- TreeRenderState _trs = null;
- public ToolTreeRootElement (String s, boolean b)
+ private String _name = null;
+ private TreeRenderState _trs = null;
+ private TreeElement _selectedNode;
+
+ public ToolTreeRootElement(String s, boolean b, int children)
{
- super (s, b);
+ super(s, b, children);
}
- public void changeSelected(String s)
+ public void changeSelected(String selectNode)
{
- //To change body of implemented methods use File | Settings | File Templates.
+ // if there is a selectedNode then we need to raise the onSelect
+ // event on that node indicating it will soon not be selected
+ TreeElement n = findNode(selectNode);
+ if (n == null) {
+ return;
+ }
+
+ // change the node that was selected so it is no longer selected
+ if (_selectedNode != null) {
+ _selectedNode.onSelect();
+ _selectedNode.setSelected(false);
+ }
+
+ // change the node that is to be selected
+ n.onSelect();
+ n.setSelected(true);
+ _selectedNode = n;
+ return;
}
public TreeRenderState getTreeRenderState()
@@ -108,17 +143,17 @@
public void setTreeRenderState(TreeRenderState treeRenderState)
{
- _trs = treeRenderState;
+ _trs = treeRenderState;
}
public void setObjectName(String s)
{
- name = s;
+ _name = s;
}
public String getObjectname()
{
- return name;
+ return _name;
}
}
}
Modified: incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tree/expand/Test.jsp
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tree/expand/Test.jsp?view=diff&r1=153524&r2=153525
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tree/expand/Test.jsp (original)
+++ incubator/beehive/trunk/netui/test/webapps/drt/coreWeb/tree/expand/Test.jsp Sat Feb 12 10:23:46 2005
@@ -1,27 +1,23 @@
<%@ taglib prefix="netui" uri="http://beehive.apache.org/netui/tags-html-1.0"%>
-<html>
+<netui:html>
<head>
- <title>
- foo
+ <title>Dynamic Tree with RunAtClient and ExpandOnClient
</title>
</head>
-<body>
-
+<netui:body>
+<h4>Dynamic Tree with RunAtClient and ExpandOnClient</h4>
+<p style="color:green">This test creates a dynamic tree that is both runAtClient and expandOnServer. The
+children are created during the onExpand method.</p>
+<netui:anchor action="reset">Reset</netui:anchor>
<!--Begin scriptContainer-->
+<div style="border: thin solid;height: 400px;">
<netui:scriptContainer>
<netui:scriptHeader/>
<netui:tree dataSource="pageFlow.root" escapeForHtml="true"
selectionAction="select" tagId="tree" runAtClient="true"
- selectionStyle="background-color: #FFD185; font-color: #FFFFFF;"
- imageRoot="/tools/framework/skins/wlp-tools/images"
- imageHandleRightLast="plus.gif"
- imageHandleRightMiddle="plus.gif"
- imageHandleDownLast="minus.gif"
- imageHandleDownMiddle="minus.gif"
- imageLineMiddle="join.gif"
- imageLineVertical="line.gif"
- imageLineLast="joinbottom.gif"/>
+ selectionStyle="background-color: #FFD185; font-color: #FFFFFF;"/>
</netui:scriptContainer>
+</div>
<!--End scriptContainer-->
- </body>
-</html>
+ </netui:body>
+</netui:html>
Modified: incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml
URL: http://svn.apache.org/viewcvs/incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml?view=diff&r1=153524&r2=153525
==============================================================================
--- incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml (original)
+++ incubator/beehive/trunk/netui/test/webapps/drt/testRecorder/config/testRecorder-tests.xml Sat Feb 12 10:23:46 2005
@@ -6546,6 +6546,19 @@
</features>
</test>
<test>
+ <name>TreeExpand</name>
+ <description>Dynamic Tree with runAtClient, expandOnServer and expansion in the onExpand method</description>
+ <webapp>coreWeb</webapp>
+ <categories>
+ <category>bvt</category>
+ <category>bvt.struts11</category>
+ <category>trees</category>
+ </categories>
+ <features>
+ <feature>Tree</feature>
+ </features>
+ </test>
+ <test>
<name>TreeMultiAttr1</name>
<description>Basic verification that setting multiple attribute with the treeHtmlAttribute</description>
<webapp>coreWeb</webapp>