You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by hu...@apache.org on 2006/12/24 23:46:08 UTC
svn commit: r490079 [1/2] - in /struts/struts2/trunk:
apps/showcase/src/main/webapp/ajax/autocompleter/
apps/showcase/src/main/webapp/ajax/remotebutton/
apps/showcase/src/main/webapp/ajax/remotediv/
apps/showcase/src/main/webapp/ajax/remotelink/ apps/s...
Author: husted
Date: Sun Dec 24 14:46:07 2006
New Revision: 490079
URL: http://svn.apache.org/viewvc?view=rev&rev=490079
Log:
WW-1554 Apply Dojo topic notification patches submitted by Musachy Barroso. Includes fixes for Dojo 0.4.
Added:
struts/struts2/trunk/apps/showcase/src/main/webapp/images/indicator.gif (with props)
Modified:
struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/autocompleter/index.jsp
struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotebutton/index.jsp
struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example2.jsp
struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example3.jsp
struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example4.jsp
struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example5.jsp
struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example8.jsp
struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example9.jsp
struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/index.jsp
struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotelink/index.jsp
struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/hangmanAjax.ftl
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/AbstractRemoteCallUIBean.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Anchor.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Autocompleter.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ComboBox.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Div.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/RemoteUICallBean.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Submit.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AbstractRemoteCallUITag.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AnchorTag.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AutocompleterTag.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/DivTag.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/SubmitTag.java
struts/struts2/trunk/core/src/main/resources/META-INF/struts-tags.tld
struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/struts/widget/Bind.js
struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/struts/widget/BindDiv.js
struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/struts/widget/ComboBox.js
struts/struts2/trunk/core/src/main/resources/template/ajax/ajax-common.ftl
struts/struts2/trunk/core/src/main/resources/template/ajax/autocompleter.ftl
struts/struts2/trunk/core/src/main/resources/template/ajax/div.ftl
struts/struts2/trunk/core/src/main/resources/template/ajax/tab-close.ftl
struts/struts2/trunk/core/src/main/resources/template/simple/autocompleter.ftl
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/AnchorTest.java
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/AutocompleterTest.java
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/DivTest.java
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/SubmitAjaxTest.java
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Autocompleter-1.txt
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Autocompleter-2.txt
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/div-1.txt
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/href-1.txt
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/submit-ajax-1.txt
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/submit-ajax-2.txt
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/submit-ajax-3.txt
Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/autocompleter/index.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/autocompleter/index.jsp?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/autocompleter/index.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/autocompleter/index.jsp Sun Dec 24 14:46:07 2006
@@ -11,10 +11,12 @@
<body>
-<s:url id="jsonList" value="/JSONList.action" />
-Using a JSON list returned from an action (href="/JSONList.action"), without autoComplete (autoComplete="false")
+<s:url id="jsonList" value="/JSONList.action"/>
+
+Using a JSON list returned from an action (href="/JSONList.action"), without autoComplete (autoComplete="false"), use indicator
<br/>
-<s:autocompleter theme="ajax" href="%{jsonList}" cssStyle="width: 200px;" autoComplete="false"/>
+<s:autocompleter name="state" theme="ajax" indicator="indicator" href="%{jsonList}" cssStyle="width: 200px;" autoComplete="false"/>
+<img id="indicator" src="${pageContext.request.contextPath}/images/indicator.gif" alt="Loading..." style="display:none"/>
<br/>
<br/>
@@ -60,9 +62,9 @@
Link two autocompleter elements. When the selected value in 'Autocompleter 1' changes, the available values in 'Autocompleter 2' will change also.
<br/>
<form id="selectForm">
- <p>Autocompleter 1 <s:autocompleter theme="simple" name="select" list="{'fruits','colors'}" value="colors" onValueChangedPublishTopic="/Refresh" forceValidOption="true"/></p>
+ <p>Autocompleter 1 <s:autocompleter theme="simple" name="select" list="{'fruits','colors'}" value="colors" notifyTopics="/Changed" forceValidOption="true" id="sel"/></p>
</form>
-Autocompleter 2 <s:autocompleter theme="ajax" href="%{#autoex}" autoComplete="false" formId="selectForm" refreshListenTopic="/Refresh" forceValidOption="true"/>
+Autocompleter 2 <s:autocompleter theme="ajax" href="%{#autoex}" autoComplete="false" formId="selectForm" listenTopics="/Changed" notifyTopics="/OpsChanged" forceValidOption="true" id="ops"/>
<br/>
<br/>
Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotebutton/index.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotebutton/index.jsp?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotebutton/index.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotebutton/index.jsp Sun Dec 24 14:46:07 2006
@@ -12,8 +12,15 @@
function after() {alert("after request");}
function handler(widget, node) {
alert('I will handle this myself!');
- dojo.byId(widget.targetsArray[0]).innerHTML = "Done";
+ dojo.byId(widget.targetsArray[0]).innerHTML = "Done";
}
+
+ dojo.event.topic.subscribe("/after", function(data, type, e){
+ alert('inside a topic event. type='+type);
+ //data : text returned
+ //type : "before", "load" or "error"
+ //e : request object
+ });
</script>
<body>
@@ -24,27 +31,34 @@
<br/><br/>
-A submit button
-<s:submit type="submit" theme="ajax" value="submit" targets="t1" href="%{ajaxTest}"/>
+A submit button, with an indicator
+<img id="indicator" src="${pageContext.request.contextPath}/images/indicator.gif" alt="Loading..." style="display:none"/>
+<s:submit type="submit" theme="ajax" value="submit" targets="t1" href="%{ajaxTest}" align="left" indicator="indicator"/>
+
+<br/><br/>
+
+A submit button, with "notifyTopics"
+<s:submit type="submit" theme="ajax" value="submit" targets="t1" href="%{ajaxTest}" align="left" notifyTopics="/after"/>
+
<br/><br/>
-Use an image as submit
+Use an image as submit
-<s:submit type="image" theme="ajax" label="Alt Text" targets="t1" src="${pageContext.request.contextPath}/images/struts-power.gif" href="%{ajaxTest}"/>
+<s:submit type="image" theme="ajax" label="Alt Text" targets="t1"
+ src="${pageContext.request.contextPath}/images/struts-power.gif" href="%{ajaxTest}" align="left" />
<br/><br/>
<label for="textInput">Text to be echoed</label>
<br/><br/>
+Use a button as submit (custom text)
<s:form id="form" action="AjaxTest">
<input type=textbox name="data">
- <s:submit type="button" theme="ajax" label="Update Content" targets="t1" id="ajaxbtn"/>
+ <s:submit type="button" theme="ajax" label="Update Content" targets="t1" id="ajaxbtn"/>
</s:form>
-Use a button as submit (custom text)
-
<br/><br/>
-
+
<s:include value="../footer.jsp"/>
</body>
Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example2.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example2.jsp?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example2.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example2.jsp Sun Dec 24 14:46:07 2006
@@ -17,10 +17,11 @@
theme="ajax"
cssStyle="border: 1px solid yellow;"
href="%{ajaxTest}"
- updateInterval="2000"
+ updateFreq="2000"
+ indicator="indicator"
>
Initial Content</s:div>
-
+<img id="indicator" src="${pageContext.request.contextPath}/images/indicator.gif" alt="Loading..." style="display:none"/>
<s:include value="../footer.jsp"/>
</body>
Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example3.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example3.jsp?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example3.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example3.jsp Sun Dec 24 14:46:07 2006
@@ -18,7 +18,7 @@
href="%{ajaxTest}"
theme="ajax"
delay="2000"
- updateInterval="%{#parameters.period}"
+ updateFreq="%{#parameters.period}"
errorText="There was an error">Initial Content</s:div>
<s:include value="../footer.jsp"/>
Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example4.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example4.jsp?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example4.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example4.jsp Sun Dec 24 14:46:07 2006
@@ -17,7 +17,7 @@
href="%{ajaxTest}"
theme="ajax"
delay="1000"
- updateInterval="5000"
+ updateFreq="5000"
errorText="There was an error"
loadingText="reloading">loading now</s:div>
Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example5.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example5.jsp?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example5.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example5.jsp Sun Dec 24 14:46:07 2006
@@ -20,6 +20,7 @@
errorText="Could not contact server"
loadingText="reloading">loading now</s:div>
+
<s:include value="../footer.jsp"/>
</body>
Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example8.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example8.jsp?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example8.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example8.jsp Sun Dec 24 14:46:07 2006
@@ -15,12 +15,12 @@
start : function() {},
stop : function() {}
};
-
-
+
+
dojo.event.topic.registerPublisher("/refresh", controller, "refresh");
dojo.event.topic.registerPublisher("/startTimer", controller, "start");
dojo.event.topic.registerPublisher("/stopTimer", controller, "stop");
-
+
</script>
<form id="form">
<label for="textInput">Text to be echoed</label>
@@ -41,10 +41,10 @@
cssStyle="border: 1px solid yellow;"
href="%{ajaxTest}"
loadingText="Loading..."
- refreshListenTopic="/refresh"
- startTimerListenTopic="/startTimer"
- stopTimerListenTopic="/stopTimer"
- updateInterval="3000"
+ listenTopics="/refresh"
+ startTimerListenTopics="/startTimer"
+ stopTimerListenTopics="/stopTimer"
+ updateFreq="3000"
autoStart="true"
formId="form"
>
Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example9.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example9.jsp?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example9.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/example9.jsp Sun Dec 24 14:46:07 2006
@@ -15,11 +15,18 @@
start : function() {},
stop : function() {}
};
-
+
dojo.event.topic.registerPublisher("/refresh", controller, "refresh");
dojo.event.topic.registerPublisher("/startTimer", controller, "start");
dojo.event.topic.registerPublisher("/stopTimer", controller, "stop");
-
+
+ dojo.event.topic.subscribe("/after", function(data, type, e){
+ alert('inside a topic event. type='+type);
+ //data : text returned
+ //type : "before", "load" or "error"
+ //e : request object
+ });
+
</script>
<input type=button value="refresh" onclick="controller.refresh()">
@@ -33,13 +40,13 @@
theme="ajax"
cssStyle="border: 1px solid yellow;"
href="%{ajaxTest}"
- refreshListenTopic="/refresh"
- startTimerListenTopic="/startTimer"
- stopTimerListenTopic="/stopTimer"
- updateInterval="10000"
+ listenTopics="/refresh"
+ startTimerListenTopics="/startTimer"
+ stopTimerListenTopics="/stopTimer"
+ updateFreq="10000"
autoStart="false"
- beforeLoading="alert('before request')"
afterLoading="alert('after request')"
+ notifyTopics="/after"
>
Initial Content</s:div>
Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/index.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/index.jsp?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/index.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotediv/index.jsp Sun Dec 24 14:46:07 2006
@@ -14,13 +14,13 @@
<li>
<a href="example1.jsp">A simple DIV that refreshes only once</a>
</li>
-
+
<li>
<a href="example10.jsp">A simple DIV that uses a custom handler</a>
</li>
<li>
- <a href="example2.jsp?url=/AjaxTest.action">A simple DIV that updates every 2 seconds</a>
+ <a href="example2.jsp?url=/AjaxTest.action">A simple DIV that updates every 2 seconds, with indicator</a>
</li>
<li>
@@ -35,13 +35,13 @@
<li>
<a href="example7.jsp">A div that calls the server, and JS in the resulting page is executed</a>
</li>
-
+
<li>
<a href="example8.jsp">A div that will listen to events to refresh and start/stop autoupdate</a>
</li>
-
+
<li>
- <a href="example9.jsp">A div that will listen to events to refresh and start/stop autoupdate and will call beforeLoading and afterLoading functions</a>
+ <a href="example9.jsp">A div that will listen to events to refresh and start/stop autoupdate, publish notifyTopics</a>
</li>
</ol>
Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotelink/index.jsp
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotelink/index.jsp?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotelink/index.jsp (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotelink/index.jsp Sun Dec 24 14:46:07 2006
@@ -8,12 +8,17 @@
</head>
<script type="text/javascript">
- function before() {alert("before request");}
- function after() {alert("after request");}
function handler(widget, node) {
alert('I will handle this myself!');
dojo.byId(widget.targetsArray[0]).innerHTML = "Done";
}
+
+ dojo.event.topic.subscribe("/after", function(data, type, e){
+ alert('inside a topic event. type='+type);
+ //data : text returned
+ //type : "before", "load" or "error"
+ //e : request object
+ });
</script>
<body>
@@ -29,10 +34,14 @@
<s:url id="ajaxTest" value="/AjaxTest.action" />
<s:url id="test3" value="/Test3.action" />
-<s:a id="link1"
+<br/><br/>
+
+<s:a
theme="ajax"
href="%{ajaxTest}"
- targets="t1,t2">Update 'Div 1' and 'Div 2'</s:a>
+ indicator="indicator"
+ targets="t1,t2" notifyTopics="/after" >Update 'Div 1' and 'Div 2', publish topic '/after', use indicator</s:a>
+<img id="indicator" src="${pageContext.request.contextPath}/images/indicator.gif" alt="Loading..." style="display:none"/>
<br/><br/>
@@ -41,16 +50,14 @@
href="/AjaxNoUrl.jsp"
errorText="Error Loading"
targets="t1">Try to update 'Div 1', use custom error message</s:a>
-
+
<br/><br/>
<s:a id="link3"
theme="ajax"
href="%{ajaxTest}"
loadingText="Loading!!!"
- beforeLoading="before()"
- afterLoading="after()"
- targets="t1">Update 'Div 1', use custom loading message, execute javascript functions before and after the request is made</s:a>
+ targets="t1">Update 'Div 1', use custom loading message</s:a>
<br/><br/>
@@ -86,9 +93,9 @@
formId="form"
>Update 'Div 2' with the content of the textbox </s:a>
-
+
<br/><br/>
-
+
<s:include value="../footer.jsp"/>
</body>
Modified: struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/hangmanAjax.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/hangmanAjax.ftl?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/hangmanAjax.ftl (original)
+++ struts/struts2/trunk/apps/showcase/src/main/webapp/hangman/hangmanAjax.ftl Sun Dec 24 14:46:07 2006
@@ -7,32 +7,44 @@
<body>
<script>
+ function destroyWidgets() {
+ var div = dojo.byId("updateCharacterAvailableDiv");
+ var anchors = div.getElementsByTagName("a");
+ dojo.lang.forEach(anchors, function(anchor){
+ var widget = dojo.widget.byId(anchor);
+ widget.destroy();
+ });
+ }
+
var _listeners = {
- guessMade: function(sourceId) {
- this.guessMadeFunc(sourceId);
- this.updateCharacterAvailable(sourceId);
- this.updateVocab(sourceId);
- this.updateScaffold(sourceId);
- this.updateGuessLeft(sourceId);
- },
- guessMadeFunc: function(sourceId) {
+ guessMade: function(sourceId, type) {
+ if(type == "before") {
+ this.guessMadeFunc(sourceId);
+ this.updateCharacterAvailable(sourceId);
+ this.updateVocab(sourceId);
+ this.updateScaffold(sourceId);
+ this.updateGuessLeft(sourceId);
+ }
+ },
+ guessMadeFunc: function(sourceId) {
var requestAttr = { character: sourceId };
dojo.io.bind({
url: "<@s.url action="guessCharacter" namespace="/hangman" />",
load: function(type, data, event) {
-
+
},
mimetype: "text/html",
content: requestAttr
- });
+ });
},
updateCharacterAvailable: function(sourceId) {
dojo.io.bind({
url: "<@s.url action="updateCharacterAvailable" namespace="/hangman/ajax" />",
load: function(type, data, event) {
var div = dojo.byId("updateCharacterAvailableDiv");
+ destroyWidgets();
div.innerHTML = data;
-
+
try{
var xmlParser = new dojo.xml.Parse();
var frag = xmlParser.parseElement(div, null, true);
@@ -50,18 +62,18 @@
},
mimetype: "text/html"
});
- },
+ },
updateVocab: function(sourceId) {
dojo.io.bind({
url: "<@s.url action="updateVocabCharacters" namespace="/hangman/ajax" />",
load: function(type, data, event) {
var div = dojo.byId("updateVocabDiv");
div.innerHTML = data;
-
+
try {
var xmlParser = new dojo.xml.Parse();
var frag = xmlParser.parseElement(div, null, true);
-
+
var scripts = div.getElementsByTagName("script");
for(var i=0; i<scripts.length; i++) {
eval(scripts[i].innerHTML);
@@ -81,11 +93,11 @@
load: function(type, data, event) {
var div = dojo.byId("updateScaffoldDiv");
div.innerHTML = data;
-
+
try {
var xmlParser = new dojo.xml.Parse();
var frag = xmlParser.parseElement(div, null, true);
-
+
var scripts = div.getElementsByTagName("script");
for(var i=0; i<scripts.length; i++) {
eval(scripts[i].innerHTML);
@@ -98,18 +110,18 @@
},
mimetype: "text/html"
});
- },
+ },
updateGuessLeft: function(sourceId) {
dojo.io.bind({
url: "<@s.url action="updateGuessLeft" namespace="/hangman/ajax" />",
load: function(type, data, event) {
var div = dojo.byId("updateGuessLeftDiv");
div.innerHTML = data;
-
+
try {
var xmlParser = new dojo.xml.Parse();
var frag = xmlParser.parseElement(div, null, true);
-
+
var scripts = div.getElementsByTagName("script");
for(var i=0; i<scripts.length; i++) {
eval(scripts[i].innerHTML);
@@ -125,20 +137,15 @@
}
};
dojo.event.topic.subscribe("topicGuessMade", _listeners, "guessMade");
- // dojo.event.topic.subscribe("topicGuessMade", _listeners, "guessMadeFunc");
- // dojo.event.topic.subscribe("topicGuessMade", _listeners, "updateCharacterAvailable");
- // dojo.event.topic.subscribe("topicGuessMade", _listeners, "updateVocab");
- // dojo.event.topic.subscribe("topicGuessMade", _listeners, "updateScaffold");
- // dojo.event.topic.subscribe("topicGuessMade", _listeners, "updateGuessLeft");
</script>
-<table bgcolor="green">
- <tr>
+<table bgcolor="green">
+ <tr>
<td>
<@s.url id="url" value="/hangman/images/hangman.png" />
<img alt="Hangman" src="<@s.property value="%{#url}" />"
- width="197" height="50" border="0"/>
- </td>
+ width="197" height="50" border="0"/>
+ </td>
<td width="70" align="right">
<#-- Guesses Left -->
<div id="updateGuessLeftDiv">
@@ -153,8 +160,8 @@
<img alt="Guesses Left"
src="<@s.property value="%{#url}" />" width="164" height="11" border="0"/>
</td>
- </tr>
- <tr>
+ </tr>
+ <tr>
<td></td>
<td align="left">
<#-- Display Scaffold -->
@@ -165,14 +172,14 @@
</div>
</td>
<td></td>
- </tr>
+ </tr>
<tr>
- <td width="160">
+ <td width="160">
<p align="right">
<@s.url id="url" value="/hangman/images/guess.png" />
<img alt="Current Guess" src="<@s.property value="%{#url}" />"
- align="MIDDLE" width="127" height="20" border="0"/></p>
- </td>
+ align="MIDDLE" width="127" height="20" border="0"/></p>
+ </td>
<td>
<#-- Display Vacab -->
<div id="updateVocabDiv">
@@ -189,18 +196,18 @@
</#if>
</...@s.iterator>
</div>
- </td>
+ </td>
</tr>
- <tr>
- <td valign="top">
+ <tr>
+ <td valign="top">
<p align="right">
<@s.url id="url" value="/hangman/images/choose.png" />
<img alt="Choose" src="<@s.property value="%{#url}" />"
height="20" width="151" border="0"/>
- </p>
- </td>
+ </p>
+ </td>
<td width="330">
-
+
<#-- Show Characters Available -->
<div id="updateCharacterAvailableDiv">
<@s.iterator id="currentCharacter" value="%{hangman.charactersAvailable}" status="stat">
@@ -211,23 +218,24 @@
<@s.url id="blankUrl" value="ajax/blank.action" includeContext="false" />
<@s.a theme="ajax"
href="%{blankUrl}"
- id="%{#currentCharacter}"
+ id="%{#currentCharacter}"
notifyTopics="topicGuessMade"
showErrorTransportText="true">
<img height="36" alt="" src="<@s.property value="%{#chalkboardImageUrl}" />" width="36" border="0" />
</...@s.a>
</...@s.iterator>
</div>
-
-
+
+
</td>
- </tr>
+ </tr>
<tr>
<td>
-
+
</td>
</tr>
</table>
</body>
</html>
+
Added: struts/struts2/trunk/apps/showcase/src/main/webapp/images/indicator.gif
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/apps/showcase/src/main/webapp/images/indicator.gif?view=auto&rev=490079
==============================================================================
Binary file - no diff available.
Propchange: struts/struts2/trunk/apps/showcase/src/main/webapp/images/indicator.gif
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/AbstractRemoteCallUIBean.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/AbstractRemoteCallUIBean.java?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/AbstractRemoteCallUIBean.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/AbstractRemoteCallUIBean.java Sun Dec 24 14:46:07 2006
@@ -23,8 +23,14 @@
import com.opensymphony.xwork2.util.ValueStack;
/**
- * AbstractRemoteCallUIBean is superclass for all components dealing with remote calls.
+ * AbstractRemoteCallUIBean is superclass for all components dealing with remote
+ * calls.
+ */
+/**
+ * TODO: Document AbstractRemoteCallUIBean.
*
+ * @author $Author$
+ * @version $Revision$ $Date$
*/
public abstract class AbstractRemoteCallUIBean extends ClosingUIBean implements RemoteUICallBean {
@@ -34,12 +40,16 @@
protected String beforeLoading;
protected String executeScripts;
protected String loadingText;
- protected String refreshListenTopic;
+ protected String listenTopics;
protected String handler;
protected String formId;
protected String formFilter;
+ protected String notifyTopics;
+ protected String showErrorTransportText;
+ protected String indicator;
- public AbstractRemoteCallUIBean(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
+ public AbstractRemoteCallUIBean(ValueStack stack, HttpServletRequest request,
+ HttpServletResponse response) {
super(stack, request, response);
}
@@ -58,31 +68,43 @@
addParameter("beforeLoading", findString(beforeLoading));
if (executeScripts != null)
addParameter("executeScripts", findValue(executeScripts, Boolean.class));
- if (refreshListenTopic != null)
- addParameter("refreshListenTopic", findValue(refreshListenTopic, String.class));
+ if (listenTopics != null)
+ addParameter("listenTopics", findValue(listenTopics, String.class));
+ if (notifyTopics != null)
+ addParameter("notifyTopics", findValue(notifyTopics, String.class));
if (handler != null)
addParameter("handler", findString(handler));
if (formId != null)
addParameter("formId", findString(formId));
if (formFilter != null)
addParameter("formFilter", findString(formFilter));
+ if (indicator != null)
+ addParameter("indicator", findString(indicator));
+ if (showErrorTransportText != null)
+ addParameter("showErrorTransportText", findValue(showErrorTransportText, Boolean.class));
+ else
+ addParameter("showErrorTransportText", true);
}
+
/* (non-Javadoc)
- * @see org.apache.struts2.components.RemoteUICallBean#setRefreshListenTopic(java.lang.String)
+ * @see org.apache.struts2.components.RemoteUICallBean#setListenTopics(java.lang.String)
*/
- public void setRefreshListenTopic(String refreshListenTopic) {
- this.refreshListenTopic = refreshListenTopic;
+ public void setListenTopics(String listenTopics) {
+ this.listenTopics = listenTopics;
}
/**
- * The theme to use for the element. <b>This tag will usually use the ajax theme.</b>
+ * The theme to use for the element. <b>This tag will usually use the ajax
+ * theme.</b>
+ *
* @s.tagattribute required="false" type="String"
*/
public void setTheme(String theme) {
super.setTheme(theme);
}
+
/* (non-Javadoc)
* @see org.apache.struts2.components.RemoteUICallBean#setHref(java.lang.String)
*/
@@ -90,6 +112,7 @@
this.href = href;
}
+
/* (non-Javadoc)
* @see org.apache.struts2.components.RemoteUICallBean#setErrorText(java.lang.String)
*/
@@ -97,6 +120,7 @@
this.errorText = errorText;
}
+
/* (non-Javadoc)
* @see org.apache.struts2.components.RemoteUICallBean#setAfterLoading(java.lang.String)
*/
@@ -104,6 +128,7 @@
this.afterLoading = afterLoading;
}
+
/* (non-Javadoc)
* @see org.apache.struts2.components.RemoteUICallBean#setBeforeLoading(java.lang.String)
*/
@@ -111,6 +136,7 @@
this.beforeLoading = beforeLoading;
}
+
/* (non-Javadoc)
* @see org.apache.struts2.components.RemoteUICallBean#setExecuteScripts(java.lang.String)
*/
@@ -125,6 +151,7 @@
this.loadingText = loadingText;
}
+
/* (non-Javadoc)
* @see org.apache.struts2.components.RemoteUICallBean#setHandler(java.lang.String)
*/
@@ -132,6 +159,7 @@
this.handler = handler;
}
+
/* (non-Javadoc)
* @see org.apache.struts2.components.RemoteUICallBean#setFormFilter(java.lang.String)
*/
@@ -145,4 +173,25 @@
public void setFormId(String formId) {
this.formId = formId;
}
+
+ /* (non-Javadoc)
+ * @see org.apache.struts2.components.RemoteUICallBean#setNotifyTopics(java.lang.String)
+ */
+ public void setNotifyTopics(String notifyTopics) {
+ this.notifyTopics = notifyTopics;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.struts2.components.RemoteUICallBean#setShowErrorTransportText(java.lang.String)
+ */
+ public void setShowErrorTransportText(String showError) {
+ this.showErrorTransportText = showError;
+ }
+
+
+ public void setIndicator(String indicator) {
+ this.indicator = indicator;
+ }
+
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Anchor.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Anchor.java?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Anchor.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Anchor.java Sun Dec 24 14:46:07 2006
@@ -36,21 +36,25 @@
* <ul>
* <li>href</li>
* <li>errorText</li>
- * <li>afterLoading</li>
- * <li>beforeLoading</li>
+ * <li>listenTopics</li>
+ * <li>notifyTopics</li>
* <li>executeScripts</li>
* <li>loadingText</li>
- * <li>refreshListenTopic</li>
+ * <li>listenTopics</li>
* <li>handler</li>
* <li>formId</li>
* <li>formFilter</li>
* <li>targets</li>
+ * <li>showErrorTransportText</li>
+ * <li>targets</li>
+ * <li>indicator</li>
* </ul>
+ * 'resultDivId' Deprecated. Use targets.<p/>
* 'targets' is a list of element ids whose content will be updated with the
* text returned from request.<p/>
* 'errorText' is the text that will be displayed when there is an error making the request.<p/>
- * 'afterLoading' is the name of a function that will be called after the request.<p/>
- * 'beforeLoading' is the name of a function that will be called before the request.<p/>
+ * 'onLoadJS' Deprecated. Use 'notifyTopics'.<p/>
+ * 'preInvokeJS' Deprecated. Use 'notifyTopics'.<p/>
* 'executeScripts' if set to true will execute javascript sections in the returned text.<p/>
* 'loadingText' is the text that will be displayed on the 'targets' elements while making the
* request.<p/>
@@ -61,7 +65,15 @@
* 'formFilter' is the name of a function which will be used to filter the fields that will be
* seralized. This function takes as a parameter the element and returns true if the element
* should be included.<p/>
- * 'refreshListenTopic' is the topic that forces an update
+ * 'listenTopics' comma separated list of topics names, that will trigger a request
+ * 'indicator' element to be shown while the request executing
+ * 'showErrorTransportText': whether errors should be displayed (on 'targets')</p>
+ * 'notifyTopics' comma separated list of topics names, that will be published. Three parameters are passed:<p/>
+ * <ul>
+ * <li>data: html or json object when type='load' or type='error'</li>
+ * <li>type: 'before' before the request is made, 'load' when the request succeeds, or 'error' when it fails</li>
+ * <li>request: request javascript object, when type='load' or type='error'</li>
+ * <ul>
* <!-- END SNIPPET: javadoc -->
*
* <p/> <b>Examples</b>
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Autocompleter.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Autocompleter.java?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Autocompleter.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Autocompleter.java Sun Dec 24 14:46:07 2006
@@ -23,8 +23,6 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import org.apache.struts2.views.util.UrlHelper;
-
import com.opensymphony.xwork2.util.ValueStack;
/**
@@ -39,10 +37,37 @@
* ["Text 3","Value3"]
* ]
* </pre>
+ * <!-- START SNIPPET: ajaxJavadoc -->
* <B>THE FOLLOWING IS ONLY VALID WHEN AJAX IS CONFIGURED</B>
* <ul>
- * <li>href - Note: The href attribute value needs to be set as an url tag id.</li>
+ * <li>href</li>
+ * <li>errorText</li>
+ * <li>listenTopics</li>
+ * <li>notifyTopics</li>
+ * <li>listenTopics</li>
+ * <li>formId</li>
+ * <li>formFilter</li>
+ * <li>indicator</li>
* </ul>
+ * 'dropdownWidth' width in pixels of the drodpdown, same as autocompleter's width by default<p/>
+ * 'dropdownHeight' height in pixels of the drodown, 120 px by default<p/>
+ * 'forceValidOption' if invalid option is selected, clear autocompleter's text when focus is lost<p/>
+ * 'autoComplete', if true, make suggestions on the textbox<p/>
+ * 'formId' is the id of the html form whose fields will be seralized and passed as parameters
+ * in the request.<p/>
+ * 'formFilter' is the name of a function which will be used to filter the fields that will be
+ * seralized. This function takes as a parameter the element and returns true if the element
+ * should be included.<p/>
+ * 'listenTopics' comma separated list of topics names, that will trigger a request
+ * 'indicator' element to be shown while the request executing
+ * 'showErrorTransportText': whether errors should be displayed (on 'targets')<p/>
+ * 'notifyTopics' comma separated list of topics names, that will be published. Three parameters are passed:<p/>
+ * <ul>
+ * <li>data: selected value when type='valuechanged'</li>
+ * <li>type: 'before' before the request is made, 'valuechanged' when selection changes, 'load' when the request succeeds, or 'error' when it fails</li>
+ * <li>request: request javascript object, when type='load' or type='error'</li>
+ * <ul>
+ *
* @s.tag name="autocompleter" tld-body-content="JSP" tld-tag-class="org.apache.struts2.views.jsp.ui.AutocompleterTag"
* description="Renders a combobox with autocomplete and AJAX capabilities"
*/
@@ -60,10 +85,9 @@
protected String dropdownHeight;
protected String formId;
protected String formFilter;
- protected String refreshListenTopic;
- protected String onValueChangedPublishTopic;
- protected String afterLoading;
- protected String beforeLoading;
+ protected String listenTopics;
+ protected String notifyTopics;
+ protected String indicator;
public Autocompleter(ValueStack stack, HttpServletRequest request,
HttpServletResponse response) {
@@ -78,8 +102,9 @@
return COMPONENT_NAME;
}
- public void evaluateParams() {
- super.evaluateParams();
+
+ public void evaluateExtraParams() {
+ super.evaluateExtraParams();
if (forceValidOption != null)
addParameter("forceValidOption", findValue(forceValidOption,
@@ -104,17 +129,19 @@
addParameter("formFilter", findString(formFilter));
if (formId != null)
addParameter("formId", findString(formId));
- if (refreshListenTopic != null)
- addParameter("refreshListenTopic", findString(refreshListenTopic));
- if (onValueChangedPublishTopic != null)
- addParameter("onValueChangedPublishTopic", findString(onValueChangedPublishTopic));
- if (afterLoading != null)
- addParameter("afterLoading", findString(afterLoading));
- if (beforeLoading != null)
- addParameter("beforeLoading", findString(beforeLoading));
+ if (listenTopics != null)
+ addParameter("listenTopics", findString(listenTopics));
+ if (notifyTopics != null)
+ addParameter("notifyTopics", findString(notifyTopics));
+ if (indicator != null)
+ addParameter("indicator", findString(indicator));
+ //get the key value
+ if(name != null) {
+ String keyNameExpr = "%{" + name + "Key}";
+ addParameter("key", findString(keyNameExpr));
+ }
}
-
protected Object findListValue() {
return (list != null) ? findValue(list, Object.class) : null;
}
@@ -208,8 +235,8 @@
*
* @s.tagattribute required="false" type="String"
*/
- public void setRefreshListenTopic(String refreshListenTopic) {
- this.refreshListenTopic = refreshListenTopic;
+ public void setListenTopics(String listenTopics) {
+ this.listenTopics = listenTopics;
}
/**
@@ -217,23 +244,15 @@
* New Value is passed as parameter.
* @s.tagattribute required="false" type="String"
*/
- public void setOnValueChangedPublishTopic(String onValueChangedPublishTopic) {
- this.onValueChangedPublishTopic = onValueChangedPublishTopic;
- }
-
- /**
- * Javascript code name that will be executed after the content has been fetched
- * @s.tagattribute required="false" type="String"
- */
- public void setAfterLoading(String afterLoading) {
- this.afterLoading = afterLoading;
+ public void setNotifyTopics(String onValueChangedPublishTopic) {
+ this.notifyTopics = onValueChangedPublishTopic;
}
/**
- * Javascript code that will be executed before the content has been fetched
+ * Id of element that will be shown while request is made
* @s.tagattribute required="false" type="String"
*/
- public void setBeforeLoading(String beforeLoading) {
- this.beforeLoading = beforeLoading;
+ public void setIndicator(String indicator) {
+ this.indicator = indicator;
}
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ComboBox.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ComboBox.java?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ComboBox.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ComboBox.java Sun Dec 24 14:46:07 2006
@@ -164,7 +164,7 @@
"You must specify a collection/array/map/enumeration/iterator. " +
"Example: people or people.{name}");
}
-
+
/**
* Iteratable source to populate from. If this is missing, the select widget is simply not displayed.
* @s.tagattribute required="true"
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Div.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Div.java?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Div.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Div.java Sun Dec 24 14:46:07 2006
@@ -24,8 +24,6 @@
import javax.servlet.http.HttpServletResponse;
import com.opensymphony.xwork2.util.ValueStack;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
/**
* <!-- START SNIPPET: javadoc -->
@@ -42,21 +40,22 @@
* <li>href</li>
* <li>errorText</li>
* <li>afterLoading</li>
- * <li>beforeLoading</li>
* <li>executeScripts</li>
* <li>loadingText</li>
- * <li>refreshListenTopic</li>
+ * <li>listenTopics</li>
* <li>handler</li>
* <li>formId</li>
* <li>formFilter</li>
* <li>targets</li>
+ * <li>notifyTopics</li>
+ * <li>showErrorTransportText</li>
+ * <li>indicator</li>
* </ul>
* 'targets' is a list of element ids whose content will be updated with the
* text returned from request.<p/>
* 'href' needs to be set as an url tag reference value.<p/>
* 'errorText' is the text that will be displayed when there is an error making the request.<p/>
- * 'afterLoading' is the name of a function that will be called after the request.<p/>
- * 'beforeLoading' is the name of a function that will be called before the request.<p/>
+ * 'afterLoading' Deprecated. Use 'notifyTopics'.<p/>
* 'executeScripts' if set to true will execute javascript sections in the returned text.<p/>
* 'loadingText' is the text that will be displayed on the 'targets' elements while making the
* request.<p/>
@@ -67,11 +66,20 @@
* 'formFilter' is the name of a function which will be used to filter the fields that will be
* seralized. This function takes as a parameter the element and returns true if the element
* should be included.<p/>
- * 'updateInterval' sets(in milliseconds) the update interval.
+ * 'updateFreq' sets(in milliseconds) the update interval.
* 'autoStart' if set to true(true by default) starts the timer automatically
- * 'startTimerListenTopic' is the topic used to start the timer
- * 'stopTimerListenTopic' is the topic used to stop the timer
- * 'refreshListenTopic' is the topic that forces an update
+ * 'startTimerListenTopics' is a comma-separated list of topics used to start the timer
+ * 'stopTimerListenTopics' is a comma-separated list of topics used to stop the timer
+ * 'listenTopics' comma separated list of topics names, that will trigger a request
+ * 'indicator' element to be shown while the request executing
+ * 'showErrorTransportText': whether errors should be displayed (on 'targets')</p>
+ * 'notifyTopics' comma separated list of topics names, that will be published. Three parameters are passed:<p>
+ * <ul>
+ * <li>data: html or json object when type='load' or type='error'</li>
+ * <li>type: 'before' before the request is made, 'load' when the request succeeds, or 'error' when it fails</li>
+ * <li>request: request javascript object, when type='load' or type='error'</li>
+ * <ul>
+
* <!-- END SNIPPET: javadoc -->
* <p/> <b>Examples</b>
*
@@ -83,8 +91,8 @@
* theme="ajax"
* href="%{url}"
* loadingText="Loading..."
- * refreshListenTopic="/refresh"
- * updateInterval="3000"
+ * listenTopics="/refresh"
+ * updateFreq="3000"
* autoStart="true"
* formId="form"
*></s:div>
@@ -96,17 +104,15 @@
*/
public class Div extends AbstractRemoteCallUIBean {
- private static final Log _log = LogFactory.getLog(Div.class);
-
public static final String TEMPLATE = "div";
public static final String TEMPLATE_CLOSE = "div-close";
public static final String COMPONENT_NAME = Div.class.getName();
- protected String updateInterval;
+ protected String updateFreq;
protected String autoStart;
protected String delay;
- protected String startTimerListenTopic;
- protected String stopTimerListenTopic;
+ protected String startTimerListenTopics;
+ protected String stopTimerListenTopics;
protected String refreshOnShow;
public Div(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
@@ -124,18 +130,18 @@
public void evaluateExtraParams() {
super.evaluateExtraParams();
- if (updateInterval != null)
- addParameter("updateInterval", findValue(updateInterval, Integer.class));
+ if (updateFreq != null)
+ addParameter("updateFreq", findValue(updateFreq, Integer.class));
if (autoStart != null)
addParameter("autoStart", findValue(autoStart, Boolean.class));
if (refreshOnShow != null)
addParameter("refreshOnShow", findValue(refreshOnShow, Boolean.class));
if (delay != null)
addParameter("delay", findValue(delay, Integer.class));
- if (startTimerListenTopic != null)
- addParameter("startTimerListenTopic", findValue(startTimerListenTopic, String.class));
- if (stopTimerListenTopic != null)
- addParameter("stopTimerListenTopic", findValue(stopTimerListenTopic, String.class));
+ if (startTimerListenTopics != null)
+ addParameter("startTimerListenTopics", findString(startTimerListenTopics));
+ if (stopTimerListenTopics != null)
+ addParameter("stopTimerListenTopics", findString(stopTimerListenTopics));
}
/**
@@ -161,8 +167,8 @@
*
* @s.tagattribute required="false" type="Integer" default="0"
*/
- public void setUpdateInterval(String updateInterval) {
- this.updateInterval = updateInterval;
+ public void setUpdateFreq(String updateInterval) {
+ this.updateFreq = updateInterval;
}
/**
@@ -170,8 +176,8 @@
*
* @s.tagattribute required="false" type="String"
*/
- public void setStartTimerListenTopic(String startTimerListenTopic) {
- this.startTimerListenTopic = startTimerListenTopic;
+ public void setStartTimerListenTopics(String startTimerListenTopic) {
+ this.startTimerListenTopics = startTimerListenTopic;
}
/**
@@ -179,8 +185,8 @@
*
* @s.tagattribute required="false" type="String"
*/
- public void setStopTimerListenTopic(String stopTimerListenTopic) {
- this.stopTimerListenTopic = stopTimerListenTopic;
+ public void setStopTimerListenTopics(String stopTimerListenTopic) {
+ this.stopTimerListenTopics = stopTimerListenTopic;
}
/**
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/RemoteUICallBean.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/RemoteUICallBean.java?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/RemoteUICallBean.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/RemoteUICallBean.java Sun Dec 24 14:46:07 2006
@@ -3,11 +3,18 @@
public interface RemoteUICallBean {
/**
- * Topic that will trigger a re-fetch
+ * Topic that will trigger the remote call
*
* @s.tagattribute required="false" type="String"
*/
- void setRefreshListenTopic(String refreshListenTopic);
+ void setListenTopics(String topics);
+
+ /**
+ * Topic that will published when the remote call completes
+ *
+ * @s.tagattribute required="false" type="String"
+ */
+ void setNotifyTopics(String topics);
/**
* The URL to call to obtain the content. Note: If used with ajax context, the value must be set as an url tag value.
@@ -67,7 +74,19 @@
* @s.tagattribute required="false" type="String"
*/
void setFormId(String formId);
-
-
-}
\ No newline at end of file
+ /**
+ * Set whether errors will be shown or not
+ *
+ * @s.tagattribute required="false" type="Boolean"
+ */
+ void setShowErrorTransportText(String showError);
+
+ /**
+ * Id of element that will be shown while making request
+ *
+ * @s.tagattribute required="false" type="String"
+ */
+ void setIndicator(String indicator);
+
+}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Submit.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Submit.java?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Submit.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Submit.java Sun Dec 24 14:46:07 2006
@@ -64,21 +64,25 @@
* <ul>
* <li>href</li>
* <li>errorText</li>
- * <li>afterLoading</li>
- * <li>beforeLoading</li>
+ * <li>listenTopics</li>
+ * <li>notifyTopics</li>
* <li>executeScripts</li>
* <li>loadingText</li>
- * <li>refreshListenTopic</li>
+ * <li>listenTopics</li>
* <li>handler</li>
* <li>formId</li>
* <li>formFilter</li>
* <li>targets</li>
+ * <li>showErrorTransportText</li>
+ * <li>targets</li>
+ * <li>indicator</li>
* </ul>
+ * 'resultDivId' Deprecated. Use targets.</p>
* 'targets' is a list of element ids whose content will be updated with the
* text returned from request.<p/>
* 'errorText' is the text that will be displayed when there is an error making the request.<p/>
- * 'afterLoading' is the name of a function that will be called after the request.<p/>
- * 'beforeLoading' is the name of a function that will be called before the request.<p/>
+ * 'onLoadJS' Deprecated. Use 'notifyTopics'.<p/>
+ * 'preInvokeJS' Deprecated. Use 'notifyTopics'.<p/>
* 'executeScripts' if set to true will execute javascript sections in the returned text.<p/>
* 'loadingText' is the text that will be displayed on the 'targets' elements while making the
* request.<p/>
@@ -89,7 +93,16 @@
* 'formFilter' is the name of a function which will be used to filter the fields that will be
* seralized. This function takes as a parameter the element and returns true if the element
* should be included.<p/>
- * 'refreshListenTopic' is the topic that forces an update
+ * 'listenTopics' comma separated list of topics names, that will trigger a request
+ * 'indicator' element to be shown while the request executing
+ * 'showErrorTransportText': whether errors should be displayed (on 'targets')</p>
+ * 'notifyTopics' comma separated list of topics names, that will be published. Three parameters are passed:<p/>
+ * <ul>
+ * <li>data: html or json object when type='load' or type='error'</li>
+ * <li>type: 'before' before the request is made, 'load' when the request succeeds, or 'error' when it fails</li>
+ * <li>request: request javascript object, when type='load' or type='error'</li>
+ * <ul>
+
* <pre>
* <!-- START SNIPPET: ajxExample1 -->
* Remote form replacing another div:
@@ -117,15 +130,23 @@
protected String href;
protected String errorText;
- protected String afterLoading;
- protected String beforeLoading;
protected String executeScripts;
protected String loadingText;
- protected String refreshListenTopic;
+ protected String listenTopics;
protected String handler;
protected String formId;
protected String formFilter;
protected String src;
+ protected String notifyTopics;
+ protected String showErrorTransportText;
+ protected String indicator;
+
+ //these two are called "preInvokeJS" and "onLoadJS" on the tld
+ //Names changed here to keep some consistency
+ protected String beforeLoading;
+ protected String afterLoading;
+
+ //this one is called "resultDivId" on the tld
protected String targets;
public Submit(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
@@ -163,8 +184,10 @@
addParameter("beforeLoading", findString(beforeLoading));
if (executeScripts != null)
addParameter("executeScripts", findValue(executeScripts, Boolean.class));
- if (refreshListenTopic != null)
- addParameter("refreshListenTopic", findValue(refreshListenTopic, String.class));
+ if (listenTopics != null)
+ addParameter("listenTopics", findString(listenTopics));
+ if (notifyTopics != null)
+ addParameter("notifyTopics", findString(notifyTopics));
if (handler != null)
addParameter("handler", findString(handler));
if (formId != null)
@@ -173,6 +196,8 @@
addParameter("formFilter", findString(formFilter));
if (src != null)
addParameter("src", findString(src));
+ if (indicator != null)
+ addParameter("indicator", findString(indicator));
if (targets != null)
addParameter("targets", findString(targets));
}
@@ -189,8 +214,8 @@
/* (non-Javadoc)
* @see org.apache.struts2.components.RemoteUICallBean#setRefreshListenTopic(java.lang.String)
*/
- public void setRefreshListenTopic(String refreshListenTopic) {
- this.refreshListenTopic = refreshListenTopic;
+ public void setListenTopics(String listenTopics) {
+ this.listenTopics = listenTopics;
}
/**
@@ -278,5 +303,28 @@
*/
public void setTargets(String targets) {
this.targets = targets;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.struts2.components.RemoteUICallBean#setNotifyTopics(java.lang.String)
+ */
+ public void setNotifyTopics(String notifyTopics) {
+ this.notifyTopics = notifyTopics;
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.apache.struts2.components.RemoteUICallBean#setShowErrorTransportText(java.lang.String)
+ */
+ public void setShowErrorTransportText(String showErrorTransportText) {
+ this.showErrorTransportText = showErrorTransportText;
+ }
+
+ /**
+ * @param indicator The indicator to set.
+ */
+ public void setIndicator(String indicator) {
+ this.indicator = indicator;
}
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AbstractRemoteCallUITag.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AbstractRemoteCallUITag.java?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AbstractRemoteCallUITag.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AbstractRemoteCallUITag.java Sun Dec 24 14:46:07 2006
@@ -22,7 +22,8 @@
public abstract class AbstractRemoteCallUITag extends AbstractClosingTag {
protected String href;
- protected String refreshListenTopic;
+ protected String listenTopics;
+ protected String notifyTopics;
protected String loadingText;
protected String errorText;
protected String beforeLoading;
@@ -31,13 +32,15 @@
protected String handler;
protected String formId;
protected String formFilter;
+ protected String showErrorTransportText;
+ protected String indicator;
protected void populateParams() {
super.populateParams();
RemoteUICallBean remote = (RemoteUICallBean) component;
remote.setHref(href);
- remote.setRefreshListenTopic(refreshListenTopic);
+ remote.setListenTopics(listenTopics);
remote.setLoadingText(loadingText);
remote.setErrorText(errorText);
remote.setAfterLoading(afterLoading);
@@ -46,6 +49,9 @@
remote.setHandler(handler);
remote.setFormFilter(formFilter);
remote.setFormId(formId);
+ remote.setNotifyTopics(notifyTopics);
+ remote.setShowErrorTransportText(showErrorTransportText);
+ remote.setIndicator(indicator);
}
public void setHref(String href) {
@@ -60,8 +66,8 @@
this.loadingText = loadingText;
}
- public void setRefreshListenTopic(String refreshListenTopic) {
- this.refreshListenTopic = refreshListenTopic;
+ public void setListenTopics(String listenTopics) {
+ this.listenTopics = listenTopics;
}
public void setAfterLoading(String afterLoading) {
@@ -86,5 +92,20 @@
public void setFormId(String formId) {
this.formId = formId;
+ }
+
+ public void setNotifyTopics(String notifyTopics) {
+ this.notifyTopics = notifyTopics;
+ }
+
+ public void setShowErrorTransportText(String showErrorTransportText) {
+ this.showErrorTransportText = showErrorTransportText;
+ }
+
+ /**
+ * @param indicator The indicator to set.
+ */
+ public void setIndicator(String indicator) {
+ this.indicator = indicator;
}
}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AnchorTag.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AnchorTag.java?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AnchorTag.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AnchorTag.java Sun Dec 24 14:46:07 2006
@@ -36,6 +36,7 @@
private static final long serialVersionUID = -1034616578492431113L;
protected String targets;
+ protected String preInvokeJS;
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
return new Anchor(stack, req, res);
@@ -45,12 +46,17 @@
super.populateParams();
Anchor link = (Anchor) component;
-
link.setTargets(targets);
}
public void setTargets(String targets) {
this.targets = targets;
}
+
+ @Deprecated()
+ public void setPreInvokeJS(String preInvokeJS) {
+ this.beforeLoading = preInvokeJS;
+ }
}
+
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AutocompleterTag.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AutocompleterTag.java?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AutocompleterTag.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/AutocompleterTag.java Sun Dec 24 14:46:07 2006
@@ -37,18 +37,16 @@
protected String forceValidOption;
protected String searchType;
protected String autoComplete;
- protected String searchDelay;
+ protected String delay;
protected String disabled;
protected String href;
protected String dropdownWidth;
protected String dropdownHeight;
protected String formId;
protected String formFilter;
- protected String refreshListenTopic;
- protected String refreshPublishTopic;
- protected String onValueChangedPublishTopic;;
- protected String afterLoading;
- protected String beforeLoading;
+ protected String listenTopics;
+ protected String notifyTopics;
+ protected String indicator;
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
return new Autocompleter(stack, req, res);
@@ -62,16 +60,15 @@
autocompleter.setDisabled(disabled);
autocompleter.setForceValidOption(forceValidOption);
autocompleter.setHref(href);
- autocompleter.setDelay(searchDelay);
+ autocompleter.setDelay(delay);
autocompleter.setSearchType(searchType);
autocompleter.setDropdownHeight(dropdownHeight);
autocompleter.setDropdownWidth(dropdownWidth);
autocompleter.setFormFilter(formFilter);
autocompleter.setFormId(formId);
- autocompleter.setRefreshListenTopic(refreshListenTopic);
- autocompleter.setOnValueChangedPublishTopic(onValueChangedPublishTopic);
- autocompleter.setBeforeLoading(beforeLoading);
- autocompleter.setAfterLoading(afterLoading);
+ autocompleter.setListenTopics(listenTopics);
+ autocompleter.setNotifyTopics(notifyTopics);
+ autocompleter.setIndicator(indicator);
}
public void setAutoComplete(String autoComplete) {
@@ -90,8 +87,8 @@
this.href = href;
}
- public void setSearchDelay(String searchDelay) {
- this.searchDelay = searchDelay;
+ public void setDelay(String searchDelay) {
+ this.delay = searchDelay;
}
public void setSearchType(String searchType) {
@@ -114,24 +111,15 @@
this.formId = formId;
}
- public void setRefreshListenTopic(String refreshListenTopic) {
- this.refreshListenTopic = refreshListenTopic;
+ public void setListenTopics(String listenTopics) {
+ this.listenTopics = listenTopics;
}
- public void setRefreshPublishTopic(String refreshPublishTopic) {
- this.refreshPublishTopic = refreshPublishTopic;
+ public void setNotifyTopics(String onValueChangedPublishTopic) {
+ this.notifyTopics = onValueChangedPublishTopic;
}
- public void setOnValueChangedPublishTopic(String onValueChangedPublishTopic) {
- this.onValueChangedPublishTopic = onValueChangedPublishTopic;
+ public void setIndicator(String indicator) {
+ this.indicator = indicator;
}
-
- public void setAfterLoading(String afterLoading) {
- this.afterLoading = afterLoading;
- }
-
- public void setBeforeLoading(String beforeLoading) {
- this.beforeLoading = beforeLoading;
- }
-
-}
\ No newline at end of file
+}
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/DivTag.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/DivTag.java?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/DivTag.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/DivTag.java Sun Dec 24 14:46:07 2006
@@ -32,13 +32,13 @@
private static final long serialVersionUID = 5309231035916461758L;
- protected String updateInterval;
+ protected String updateFreq;
protected String autoStart;
protected String delay;
- protected String startTimerListenTopic;
- protected String stopTimerListenTopic;
+ protected String startTimerListenTopics;
+ protected String stopTimerListenTopics;
protected String refreshOnShow;
-
+
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
return new Div(stack, req, res);
}
@@ -47,11 +47,12 @@
super.populateParams();
Div div = (Div) component;
- div.setUpdateInterval(updateInterval);
+ div.setUpdateFreq(updateFreq);
div.setAutoStart(autoStart);
div.setDelay(delay);
- div.setStartTimerListenTopic(startTimerListenTopic);
- div.setStopTimerListenTopic(stopTimerListenTopic);
+ div.setStartTimerListenTopics(startTimerListenTopics);
+ div.setStopTimerListenTopics(stopTimerListenTopics);
+ div.setRefreshOnShow(refreshOnShow);
}
public void setAutoStart(String autoStart) {
@@ -62,16 +63,16 @@
this.delay = delay;
}
- public void setUpdateInterval(String updateInterval) {
- this.updateInterval = updateInterval;
+ public void setUpdateFreq(String updateInterval) {
+ this.updateFreq = updateInterval;
}
- public void setStartTimerListenTopic(String startTimerListenTopic) {
- this.startTimerListenTopic = startTimerListenTopic;
+ public void setStartTimerListenTopics(String startTimerListenTopic) {
+ this.startTimerListenTopics = startTimerListenTopic;
}
- public void setStopTimerListenTopic(String stopTimerListenTopic) {
- this.stopTimerListenTopic = stopTimerListenTopic;
+ public void setStopTimerListenTopics(String stopTimerListenTopic) {
+ this.stopTimerListenTopics = stopTimerListenTopic;
}
public void setRefreshOnShow(String refreshOnShow) {
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/SubmitTag.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/SubmitTag.java?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/SubmitTag.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/views/jsp/ui/SubmitTag.java Sun Dec 24 14:46:07 2006
@@ -40,16 +40,24 @@
protected String align;
protected String type;
protected String href;
- protected String refreshListenTopic;
+ protected String listenTopics;
+ protected String notifyTopics;
protected String loadingText;
protected String errorText;
- protected String beforeLoading;
- protected String afterLoading;
protected String executeScripts;
protected String handler;
protected String formId;
protected String formFilter;
protected String src;
+ protected String showErrorTransportText;
+ protected String indicator;
+
+ //these two are called "preInvokeJS" and "onLoadJS" on the tld
+ //Names changed here to keep some consistency
+ protected String beforeLoading;
+ protected String afterLoading;
+
+ //this one is called "resultDivId" on the tld
protected String targets;
public Component getBean(ValueStack stack, HttpServletRequest req, HttpServletResponse res) {
@@ -65,7 +73,7 @@
submit.setAlign(align);
submit.setType(type);
submit.setHref(href);
- submit.setRefreshListenTopic(refreshListenTopic);
+ submit.setListenTopics(listenTopics);
submit.setLoadingText(loadingText);
submit.setErrorText(errorText);
submit.setAfterLoading(afterLoading);
@@ -76,6 +84,9 @@
submit.setFormId(formId);
submit.setSrc(src);
submit.setTargets(targets);
+ submit.setNotifyTopics(notifyTopics);
+ submit.setShowErrorTransportText(showErrorTransportText);
+ submit.setIndicator(indicator);
}
public void setAction(String action) {
@@ -110,16 +121,8 @@
this.loadingText = loadingText;
}
- public void setRefreshListenTopic(String refreshListenTopic) {
- this.refreshListenTopic = refreshListenTopic;
- }
-
- public void setAfterLoading(String afterLoading) {
- this.afterLoading = afterLoading;
- }
-
- public void setBeforeLoading(String beforeLoading) {
- this.beforeLoading = beforeLoading;
+ public void setListenTopics(String listenTopics) {
+ this.listenTopics = listenTopics;
}
public void setExecuteScripts(String executeScripts) {
@@ -144,5 +147,32 @@
public void setTargets(String targets) {
this.targets = targets;
+ }
+
+ @Deprecated
+ public void setResultDivId(String id) {
+ this.targets = id;
+ }
+
+ @Deprecated
+ public void setOnLoadJS(String postJS) {
+ this.afterLoading = postJS;
+ }
+
+ @Deprecated
+ public void setPreInvokeJS(String preJS) {
+ this.beforeLoading = preJS;
+ }
+
+ public void setNotifyTopics(String notifyTopics) {
+ this.notifyTopics = notifyTopics;
+ }
+
+ public void setShowErrorTransportText(String showErrorTransportText) {
+ this.showErrorTransportText = showErrorTransportText;
+ }
+
+ public void setIndicator(String indicator) {
+ this.indicator = indicator;
}
}
Modified: struts/struts2/trunk/core/src/main/resources/META-INF/struts-tags.tld
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/META-INF/struts-tags.tld?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/META-INF/struts-tags.tld (original)
+++ struts/struts2/trunk/core/src/main/resources/META-INF/struts-tags.tld Sun Dec 24 14:46:07 2006
@@ -1610,6 +1610,14 @@
</attribute>
<attribute>
+ <name>indicator</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Id of element that will be show while doing the request]]></description>
+
+ </attribute>
+ <attribute>
<name>targets</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
@@ -1651,12 +1659,21 @@
</attribute>
<attribute>
- <name>refreshListenTopic</name>
+ <name>listenTopics</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description>
+ <![CDATA[Topic names to listen to (comma delimited)]]></description>
+
+ </attribute>
+ <attribute>
+ <name>notifyTopics</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>
- <![CDATA[Topic name to listen to (comma delimited), that will cause the DIV's content to be re-fetched]]></description>
+ <![CDATA[Topic names to publish (comma delimited)]]></description>
</attribute>
<attribute>
@@ -1677,21 +1694,39 @@
</attribute>
<attribute>
- <name>beforeLoading</name>
+ <name>preInvokeJS</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>
- <![CDATA[Javascript code that will be executed before the content has been fetched]]></description>
+ <![CDATA[Deprecated. Use "notifyTopics".]]></description>
</attribute>
<attribute>
- <name>afterLoading</name>
+ <name>onLoadJS</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description>
+ <![CDATA[Deprecated. Use "notifyTopics".]]></description>
+
+ </attribute>
+ <attribute>
+ <name>showErrorTransportText</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>
- <![CDATA[Javascript code that will be executed after the content has been fetched]]></description>
+ <![CDATA[Set whether errors will be shown or not]]></description>
+
+ </attribute>
+ <attribute>
+ <name>resultDivId</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description>
+ <![CDATA[Deprecated. Use "targets".]]></description>
</attribute>
<attribute>
@@ -2406,7 +2441,15 @@
<description><![CDATA[Render HTML div providing content from remote call via AJAX]]></description>
<attribute>
- <name>updateInterval</name>
+ <name>indicator</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Id of element that will be show while doing the request]]></description>
+
+ </attribute>
+ <attribute>
+ <name>updateFreq</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
@@ -2414,6 +2457,14 @@
</attribute>
<attribute>
+ <name>refreshOnShow</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[Reload content when selected. Only valid inside tabbedPanel.]]></description>
+
+ </attribute>
+ <attribute>
<name>handler</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
@@ -2471,65 +2522,74 @@
</attribute>
<attribute>
- <name>refreshListenTopic</name>
+ <name>listenTopics</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>
- <![CDATA[Topic name to listen to (comma delimited), that will cause the DIV's content to be re-fetched]]></description>
+ <![CDATA[Topic names to listen to (comma delimited)]]></description>
</attribute>
<attribute>
- <name>startTimerListenTopic</name>
+ <name>notifyTopics</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>
- <![CDATA[Topic name to listen to (comma delimited), that will cause the auto updater timer to start]]></description>
+ <![CDATA[Topic names to publish (comma delimited)]]></description>
</attribute>
<attribute>
- <name>stopTimerListenTopic</name>
+ <name>startTimerListenTopics</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>
- <![CDATA[Topic name to listen to (comma delimited), that will cause the auto updater timer to stop]]></description>
+ <![CDATA[Topic names to listen to (comma delimited), that will cause the auto updater timer to start]]></description>
</attribute>
<attribute>
- <name>theme</name>
+ <name>stopTimerListenTopics</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>
- <![CDATA[The theme to use for the element. <b>This tag will usually use the ajax theme.</b>]]></description>
+ <![CDATA[Topic names to listen to (comma delimited), that will cause the auto updater timer to stop]]></description>
</attribute>
<attribute>
- <name>href</name>
+ <name>showErrorTransportText</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
- <description><![CDATA[The URL to call to obtain the content]]></description>
+ <description>
+ <![CDATA[Set whether errors will be shown or not]]></description>
</attribute>
<attribute>
- <name>errorText</name>
+ <name>theme</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>
- <![CDATA[The text to display to the user if the is an error fetching the content]]></description>
+ <![CDATA[The theme to use for the element. <b>This tag will usually use the ajax theme.</b>]]></description>
+
+ </attribute>
+ <attribute>
+ <name>href</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description><![CDATA[The URL to call to obtain the content]]></description>
</attribute>
<attribute>
- <name>beforeLoading</name>
+ <name>errorText</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>
- <![CDATA[Javascript code that will be executed before the content has been fetched]]></description>
+ <![CDATA[The text to display to the user if the is an error fetching the content]]></description>
</attribute>
<attribute>
@@ -2538,7 +2598,7 @@
<rtexprvalue>true</rtexprvalue>
<description>
- <![CDATA[Javascript code that will be executed after the content has been fetched]]></description>
+ <![CDATA[Deprecated. Use "notifyTopics".]]></description>
</attribute>
<attribute>
@@ -2818,34 +2878,24 @@
<body-content>JSP</body-content>
<description><![CDATA[Render HTML div providing content from remote call via AJAX]]></description>
- <attribute>
- <name>autoComplete</name>
- <required>false</required>
- <rtexprvalue>true</rtexprvalue>
-
- <description><![CDATA[sets if combobox must perform autocomplete]]></description>
-
- </attribute>
<attribute>
- <name>beforeLoading</name>
+ <name>indicator</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
- <description>
- <![CDATA[Javascript code that will be executed before the content has been fetched]]></description>
+ <description><![CDATA[Id of element that will be show while doing the request]]></description>
</attribute>
- <attribute>
- <name>afterLoading</name>
+ <attribute>
+ <name>autoComplete</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
- <description>
- <![CDATA[Javascript code that will be executed after the content has been fetched]]></description>
+ <description><![CDATA[sets if combobox must perform autocomplete]]></description>
</attribute>
<attribute>
- <name>refreshListenTopic</name>
+ <name>listenTopics</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
@@ -2854,7 +2904,7 @@
</attribute>
<attribute>
- <name>onValueChangedPublishTopic</name>
+ <name>notifyTopics</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
@@ -8004,7 +8054,14 @@
<description>
<![CDATA[Render a HTML href element that when clicked calls a URL via remote XMLHttpRequest]]>
</description>
+ <attribute>
+ <name>indicator</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <description><![CDATA[Id of element that will be show while doing the request]]></description>
+
+ </attribute>
<attribute>
<name>executeScripts</name>
<required>false</required>
@@ -8043,16 +8100,34 @@
<rtexprvalue>true</rtexprvalue>
<description>
- <![CDATA[The text to display to the user while the new content is being fetched (especially good if the content will take awhile)]]></description>
+ <![CDATA[The text to display to the user while the new content is being fetched.]]></description>
+
+ </attribute>
+ <attribute>
+ <name>listenTopics</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description>
+ <![CDATA[Topic names to listen to (comma delimited) to trigger an update]]></description>
+
+ </attribute>
+ <attribute>
+ <name>notifyTopics</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+
+ <description>
+ <![CDATA[Topic names to publish (comma delimited)]]></description>
</attribute>
<attribute>
- <name>refreshListenTopic</name>
+ <name>showErrorTransportText</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>
- <![CDATA[Topic name to listen to (comma delimited), that will cause the DIV's content to be re-fetched]]></description>
+ <![CDATA[Set whether errors will be shown or not]]></description>
</attribute>
<attribute>
@@ -8082,12 +8157,12 @@
</attribute>
<attribute>
- <name>beforeLoading</name>
+ <name>preInvokeJS</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
<description>
- <![CDATA[Javascript code that will be executed before the content has been fetched]]></description>
+ <![CDATA[Deprecated. Use "beforeLoading"]]></description>
</attribute>
<attribute>
Modified: struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/struts/widget/Bind.js
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/struts/widget/Bind.js?view=diff&rev=490079&r1=490078&r2=490079
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/struts/widget/Bind.js (original)
+++ struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/struts/widget/Bind.js Sun Dec 24 14:46:07 2006
@@ -16,9 +16,12 @@
//messages
loadingText : "Loading...",
errorText : "",
+ showError : true,
//pub/sub events
- refreshListenTopic : "",
+ listenTopics : "",
+ notifyTopics : "",
+ notifyTopicsArray : null,
//callbacks
beforeLoading : "",
@@ -29,21 +32,29 @@
formNode : null,
event : "",
+ indicator : "",
- onDownloadStart : function(event) {
- if(!dojo.string.isBlank(this.beforeLoading)) {
- eval(this.beforeLoading);
- }
- if(!dojo.string.isBlank(this.loadingText)) {
- event.text = this.loadingText;
- }
- },
+ parseContent : true,
postCreate : function() {
//attach listeners
- if(!dojo.string.isBlank(this.refreshListenTopic)) {
- this.log("Listening to " + this.refreshListenTopic + " to refresh");
- dojo.event.topic.subscribe(this.refreshListenTopic, this, "reloadContents");
+ if(!dojo.string.isBlank(this.listenTopics)) {
+ this.log("Listening to " + this.listenTopics + " to refresh");
+ var topics = this.listenTopics.split(",");
+ if(topics) {
+ var self = this;
+ if(topics) {
+ if(topics) {
+ dojo.lang.forEach(topics, function(topic){
+ dojo.event.topic.subscribe(topic, self, "reloadContents");
+ });
+ }
+ }
+ }
+ }
+
+ if(!dojo.string.isBlank(this.notifyTopics)) {
+ this.notifyTopicsArray = this.notifyTopics.split(",");
}
if(!dojo.string.isBlank(this.targets)) {
@@ -62,21 +73,37 @@
},
log : function(text) {
- dojo.debug("[" + this.widgetId + "] " + text);
+ dojo.debug("[" + (this.widgetId ? this.widgetId : "unknown") + "] " + text);
},
setContent : function(text) {
- dojo.lang.forEach(this.targetsArray, function(target) {
- dojo.byId(target).innerHTML = text;
- });
+ if(this.targetsArray) {
+ var self = this;
+ var xmlParser = new dojo.xml.Parse();
+ dojo.lang.forEach(this.targetsArray, function(target) {
+
+ var node = dojo.byId(target);
+ node.innerHTML = text;
+ if(self.parseContent){
+ var frag = xmlParser.parseElement(node, null, true);
+ dojo.widget.getParser().createSubComponents(frag, dojo.widget.byId(target));
+ }
+ });
+ }
},
bindHandler : function(type, data, e) {
+ //hide indicator
+ dojo.html.hide(this.indicator);
+
//post script
if(!dojo.string.isBlank(this.afterLoading)) {
- this.log("Executing " + this.beforeLoading);
+ this.log("Executing " + this.afterLoading);
eval(this.afterLoading);
}
+ //publish topics
+ this.notify(data, type, e);
+
if(type == "load") {
if(this.executeScripts) {
//update targets content
@@ -95,11 +122,36 @@
this.setContent(data);
}
} else {
- var message = dojo.string.isBlank(this.errorText) ? e.message : this.errorText;
- this.setContent(message);
+ if(this.showError) {
+ var message = dojo.string.isBlank(this.errorText) ? e.message : this.errorText;
+ this.setContent(message);
+ }
}
},
+ notify : function(data, type, e) {
+ if(this.notifyTopicsArray) {
+ dojo.lang.forEach(this.notifyTopicsArray, function(topic) {
+ try {
+ dojo.event.topic.publish(topic, data, type, null);
+ } catch(e){}
+ });
+ }
+ },
+
+ onDownloadStart : function(event) {
+ if(!dojo.string.isBlank(this.beforeLoading)) {
+ //for backward compatibility
+ var data = null;
+ var type = null;
+
+ eval(this.beforeLoading);
+ }
+ if(!dojo.string.isBlank(this.loadingText)) {
+ event.text = this.loadingText;
+ }
+ },
+
reloadContents : function() {
if(!dojo.string.isBlank(this.handler)) {
//use custom handler
@@ -110,10 +162,18 @@
//pre script
if(!dojo.string.isBlank(this.beforeLoading)) {
this.log("Executing " + this.beforeLoading);
+ //backward compatibility
+ var data = null;
+ var type = null;
+
eval(this.beforeLoading);
}
+
+ //show indicator
+ dojo.html.show(this.indicator);
try {
var self = this;
+ this.notify(this.widgetId, "before", {});
this.setContent(this.loadingText);
dojo.io.bind({
url: self.href,
@@ -181,5 +241,6 @@
};
}
});
+