mirror of
https://github.com/apache/struts.git
synced 2026-08-06 07:06:58 +00:00
WW-1293
git-svn-id: https://svn.apache.org/repos/asf/struts/action2/trunk@408019 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
+30
@@ -0,0 +1,30 @@
|
||||
package org.apache.struts.action2.showcase;
|
||||
|
||||
import org.apache.struts.action2.showcase.ajax.tree.Category;
|
||||
|
||||
import com.opensymphony.xwork.ActionSupport;
|
||||
|
||||
public class DynamicTreeSelectAction extends ActionSupport {
|
||||
|
||||
private long nodeId;
|
||||
private Category currentCategory;
|
||||
|
||||
|
||||
public void setNodeId(long nodeId) {
|
||||
this.nodeId = nodeId;
|
||||
}
|
||||
public long getNodeId() {
|
||||
return nodeId;
|
||||
}
|
||||
|
||||
|
||||
public String execute() throws Exception {
|
||||
currentCategory = Category.getById(nodeId);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
public String getNodeName() {
|
||||
return currentCategory.getName();
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package org.apache.struts.action2.showcase;
|
||||
|
||||
import org.apache.struts.action2.showcase.ajax.tree.Category;
|
||||
|
||||
import com.opensymphony.xwork.ActionSupport;
|
||||
|
||||
|
||||
public class ShowDynamicTreeAction extends ActionSupport {
|
||||
|
||||
public Category getTreeRootNode() {
|
||||
return Category.getById(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,5 +36,18 @@
|
||||
<action name="tooltipExample">
|
||||
<result>tooltipExample.jsp</result>
|
||||
</action>
|
||||
<action name="showDynamicTreeAction" class="org.apache.struts.action2.showcase.ShowDynamicTreeAction">
|
||||
<result>/tags/ui/treeExampleDynamic.jsp</result>
|
||||
</action>
|
||||
</package>
|
||||
|
||||
<package name="ui-tags-ajax" namespace="/tags/ui/ajax" extends="struts-default">
|
||||
<!-- Actions dealing with Tree Example -->
|
||||
<action name="staticTreeSelectAction">
|
||||
<result>/tags/ui/staticTreeSelect.jsp</result>
|
||||
</action>
|
||||
<action name="dynamicTreeSelectAction" class="org.apache.struts.action2.showcase.DynamicTreeSelectAction">
|
||||
<result>/tags/ui/dynamicTreeSelect.jsp</result>
|
||||
</action>
|
||||
</package>
|
||||
</xwork>
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
<pattern>/ajax/AjaxResult*</pattern>
|
||||
<pattern>/AjaxTest.action</pattern>
|
||||
<pattern>/ajax/remoteforms/AjaxRemoteForm.action</pattern>
|
||||
<pattern>/tags/ui/ajax/*</pattern>
|
||||
</excludes>
|
||||
|
||||
<decorator name="main" page="main.jsp">
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<%@taglib prefix="saf" uri="/struts-action" %>
|
||||
|
||||
Id:<saf:property value="%{nodeId}" /><br/>
|
||||
Name:<saf:property value="%{nodeName}" /><br/>
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
<li><saf:url id="url" namespace="/tags/ui" action="exampleVelocity" method="input" /><saf:a href="%{url}">UI Example (Velocity)</saf:a></li>
|
||||
<li><saf:url id="url" namespace="/tags/ui" action="lotsOfOptiontransferselect" method="input" /><saf:a href="%{url}">Option Transfer Select UI Example</saf:a></li>
|
||||
<li><saf:url id="url" namespace="/tags/ui" action="lotsOfRichtexteditor" method="input" /><saf:a href="%{url}">Rich Text Editor UI Example</saf:a></li>
|
||||
<li><saf:url id="url" namespace="/tags/ui" value="treeExampleStatic.jsp" /><saf:a href="%{url}">Tree Example (static)</saf:a>
|
||||
<li><saf:url id="url" namespace="/tags/ui" action="showDynamicTreeAction"/><saf:a href="%{url}">Tree Example (dynamic)</saf:a>
|
||||
<%--li><saf:url id="url" namespace="/tags/ui" action="populateUsingIterator" method="input" /><saf:a href="%{url}">UI population using iterator tag</saf:a></li--%>
|
||||
</ul>
|
||||
</body>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<%@taglib prefix="saf" uri="/struts-action" %>
|
||||
|
||||
<%
|
||||
request.setAttribute("decorator", "none");
|
||||
response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
|
||||
response.setHeader("Pragma","no-cache"); //HTTP 1.0
|
||||
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
|
||||
%>
|
||||
|
||||
|
||||
<%--
|
||||
<script>
|
||||
var widget = dojo.widget.byId("parentId");
|
||||
alert(widget.selectedNode);
|
||||
if (widget.selectedNode != null) {
|
||||
var inputElement = dojo.byId('sId');
|
||||
inputElement.value='true';
|
||||
alert(inputElement+'\t'+inputElement.value);
|
||||
}
|
||||
else {
|
||||
var inputElement = dojo.byId('sId');
|
||||
inputElement.value='false';
|
||||
alert(inputElement+'\t'+inputElement.value);
|
||||
}
|
||||
</script>
|
||||
--%>
|
||||
|
||||
<%=request.getParameter("nodeId") %>
|
||||
@@ -0,0 +1,44 @@
|
||||
<%@taglib prefix="saf" uri="/struts-action" %>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Showcase - UI Tag Example - Tree Example (Dynamic)</title>
|
||||
<saf:head theme="ajax" debug="true" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script>
|
||||
function treeNodeSelected(nodeId) {
|
||||
dojo.io.bind({
|
||||
url: "<saf:url value='/tags/ui/ajax/dynamicTreeSelectAction.action' />?nodeId="+nodeId,
|
||||
load: function(type, data, evt) {
|
||||
var displayDiv = dojo.byId("displayId");
|
||||
displayDiv.innerHTML = data;
|
||||
},
|
||||
mimeType: "text/html"
|
||||
});
|
||||
};
|
||||
|
||||
dojo.event.topic.subscribe("treeSelected", "treeNodeSelected");
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<div style="float:left; margin-right: 50px;">
|
||||
<saf:tree
|
||||
theme="ajax"
|
||||
rootNode="%{treeRootNode}"
|
||||
childCollectionProperty="children"
|
||||
nodeIdProperty="id"
|
||||
nodeTitleProperty="name"
|
||||
treeSelectedTopic="treeSelected">
|
||||
</saf:tree>
|
||||
</div>
|
||||
|
||||
<div id="displayId">
|
||||
Please click on any of the tree nodes.
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,50 @@
|
||||
<%@taglib prefix="saf" uri="/struts-action" %>
|
||||
<html>
|
||||
<head>
|
||||
<title>Showcase - UI Tag Example - Tree Example (Static)</title>
|
||||
<saf:head theme="ajax" debug="true" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script>
|
||||
function treeNodeSelected(nodeId) {
|
||||
dojo.io.bind({
|
||||
url: "<saf:url value='/tags/ui/ajax/staticTreeSelectAction.action'/>?nodeId="+nodeId,
|
||||
load: function(type, data, evt) {
|
||||
var divDisplay = dojo.byId("displayIt");
|
||||
divDisplay.innerHTML=data;
|
||||
},
|
||||
mimeType: "text/html"
|
||||
});
|
||||
};
|
||||
|
||||
dojo.event.topic.subscribe("treeSelected", "treeNodeSelected");
|
||||
</script>
|
||||
|
||||
|
||||
<div style="float:left; margin-right: 50px;">
|
||||
<saf:tree label="parent" id="parentId" theme="ajax" templateCssPath="/struts/tree.css"
|
||||
showRootGrid="true" showGrid="true" treeSelectedTopic="treeSelected">
|
||||
<saf:treenode theme="ajax" label="child1" id="child1Id">
|
||||
<saf:treenode theme="ajax" label="grandchild1" id="grandchild1Id"/>
|
||||
<saf:treenode theme="ajax" label="grandchild2" id="grandchild2Id"/>
|
||||
<saf:treenode theme="ajax" label="grandchild3" id="grandchild3Id"/>
|
||||
</saf:treenode>
|
||||
<saf:treenode theme="ajax" label="child2" id="child2Id"/>
|
||||
<saf:treenode theme="ajax" label="child3" id="child3Id"/>
|
||||
<saf:treenode theme="ajax" label="child4" id="child4Id"/>
|
||||
<saf:treenode theme="ajax" label="child5" id="child5Id">
|
||||
<saf:treenode theme="ajax" label="gChild1" id="gChild1Id"/>
|
||||
<saf:treenode theme="ajax" label="gChild2" id="gChild2Id"/>
|
||||
</saf:treenode>
|
||||
</saf:tree>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="displayIt">
|
||||
Please click on any node on the tree.
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user