You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by he...@apache.org on 2006/11/16 17:58:58 UTC
svn commit: r475814 - in /struts/struts2/trunk:
apps/showcase/src/main/webapp/ajax/remotebutton/
core/src/main/java/org/apache/struts2/components/
core/src/main/resources/org/apache/struts2/static/dojo/struts/widget/
core/src/main/resources/template/ajax/
Author: hermanns
Date: Thu Nov 16 08:58:57 2006
New Revision: 475814
URL: http://svn.apache.org/viewvc?view=rev&rev=475814
Log:
upgrade struts2 dojo widget due to upgrading dojo to 0.4
o applying latest patch set (WW-1484_2.patch)
Issue Number: WW-1484
Submitted by: Musachy Barroso
Modified:
struts/struts2/trunk/apps/showcase/src/main/webapp/ajax/remotebutton/index.jsp
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Anchor.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/Submit.java
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/TabbedPanel.java
struts/struts2/trunk/core/src/main/resources/org/apache/struts2/static/dojo/struts/widget/Bind.js
struts/struts2/trunk/core/src/main/resources/template/ajax/form.ftl
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=475814&r1=475813&r2=475814
==============================================================================
--- 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 Thu Nov 16 08:58:57 2006
@@ -35,11 +35,12 @@
<label for="textInput">Text to be echoed</label>
<br/><br/>
-<form id="form">
+<s:form id="form" action="AjaxTest">
<input type=textbox name="data">
-</form>
+ <s:submit type="button" theme="ajax" label="Update Content" targets="t1" id="ajaxbtn"/>
+</s:form>
Use a button as submit (custom text)
-<s:submit type="button" theme="ajax" label="Update Content" targets="t1" href="/AjaxTest.action" formId="form"/>
+
<br/><br/>
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=475814&r1=475813&r2=475814
==============================================================================
--- 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 Thu Nov 16 08:58:57 2006
@@ -29,10 +29,39 @@
* <!-- START SNIPPET: javadoc -->
*
* A tag that creates a HTML <a href='' /> that when clicked calls a URL remote XMLHttpRequest call via the dojo
- * framework. The 'targets' attribute can hold a comma-delimited list of ids of the elements whose
- * content will be replaced with the response of the request.The result from the URL is executed as JavaScript is executeScripts is set to 'true'. If a
- * 'refreshListenTopic' is supplied, it will listen to that event and update its targets contents.
+ * framework.<p/>
*
+ * <!-- START SNIPPET: ajaxJavadoc -->
+ * <B>THE FOLLOWING IS ONLY VALID WHEN AJAX IS CONFIGURED</B>
+ * <ul>
+ * <li>href</li>
+ * <li>errorText</li>
+ * <li>afterLoading</li>
+ * <li>beforeLoading</li>
+ * <li>executeScripts</li>
+ * <li>loadingText</li>
+ * <li>refreshListenTopic</li>
+ * <li>handler</li>
+ * <li>formId</li>
+ * <li>formFilter</li>
+ * <li>targets</li>
+ * </ul>
+ * '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/>
+ * '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/>
+ * 'handler' is the name of the function that will take care of making the AJAX request. Dojo's widget
+ * and dom node are passed as parameters).<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/>
+ * 'refreshListenTopic' is the topic that forces an update
* <!-- END SNIPPET: javadoc -->
*
* <p/> <b>Examples</b>
@@ -74,20 +103,21 @@
*
* <pre>
* <!-- START SNIPPET: example3 -->
- * <s:a id="test" theme="ajax" href="/simpeResult.action" beforeLoading="confirm(\'You sure\')">
+ * <s:a id="test" theme="ajax" href="/simpeResult.action" beforeLoading="confirm('Are you sure?')">
* A
* </s:a>
* <!-- END SNIPPET: example3 -->
* </pre>
*
+ *
* @s.tag name="a" tld-body-content="JSP" tld-tag-class="org.apache.struts2.views.jsp.ui.AnchorTag"
* description="Render a HTML href element that when clicked calls a URL via remote XMLHttpRequest and updates its targets"
*
*/
public class Anchor extends AbstractRemoteCallUIBean {
- final public static String OPEN_TEMPLATE = "a";
- final public static String TEMPLATE = "a-close";
- final public static String COMPONENT_NAME = Anchor.class.getName();
+ public static final String OPEN_TEMPLATE = "a";
+ public static final String TEMPLATE = "a-close";
+ public static final String COMPONENT_NAME = Anchor.class.getName();
protected String targets;
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=475814&r1=475813&r2=475814
==============================================================================
--- 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 Thu Nov 16 08:58:57 2006
@@ -28,24 +28,65 @@
import org.apache.commons.logging.LogFactory;
/**
- * <!-- START SNIPPET: javadoc --> The div tag is primarily an AJAX tag, providing a remote call
+ * <!-- START SNIPPET: javadoc -->
+ * The div tag when used on the ajax theme, provides a remote call
* from the current page to update a section of content without having to refresh the entire page.<p/>
*
* It creates a HTML <DIV /> that obtains it's content via a remote XMLHttpRequest call via
* the dojo framework.<p/>
*
- * If a "refreshListenTopic" is supplied, it will listen to that topic and refresh it's content when any
- * message is received.<p/> <!-- END SNIPPET: javadoc -->
- *
- * <b>Important:</b> Be sure to setup the page containing this tag to be Configured for AJAX
* </p>
- *
+ * <!-- START SNIPPET: ajaxJavadoc -->
+ * <B>THE FOLLOWING IS ONLY VALID WHEN AJAX IS CONFIGURED</B>
+ * <ul>
+ * <li>href</li>
+ * <li>errorText</li>
+ * <li>afterLoading</li>
+ * <li>beforeLoading</li>
+ * <li>executeScripts</li>
+ * <li>loadingText</li>
+ * <li>refreshListenTopic</li>
+ * <li>handler</li>
+ * <li>formId</li>
+ * <li>formFilter</li>
+ * <li>targets</li>
+ * </ul>
+ * '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/>
+ * '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/>
+ * 'handler' is the name of the function that will take care of making the AJAX request. Dojo's widget
+ * and dom node are passed as parameters).<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/>
+ * 'updateInterval' 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
+ * <!-- END SNIPPET: javadoc -->
* <p/> <b>Examples</b>
*
* <pre>
- * <!-- START SNIPPET: example -->
- * <s:div ... />
- * <!-- END SNIPPET: example -->
+ * <!-- START SNIPPET: example -->
+ * <s:div
+ * id="once"
+ * theme="ajax"
+ * href="/AjaxTest.action"
+ * loadingText="Loading..."
+ * refreshListenTopic="/refresh"
+ * updateInterval="3000"
+ * autoStart="true"
+ * formId="form"
+ *></s:div>
+ * <!-- END SNIPPET: example -->
* </pre>
*
* @s.tag name="div" tld-body-content="JSP" tld-tag-class="org.apache.struts2.views.jsp.ui.DivTag"
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=475814&r1=475813&r2=475814
==============================================================================
--- 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 Thu Nov 16 08:58:57 2006
@@ -41,20 +41,17 @@
* <!-- END SNIPPET: javadoc -->
*
* <p/> <b>Examples</b>
- *
* <pre>
* <!-- START SNIPPET: example -->
* <s:submit value="%{'Submit'}" />
* <!-- END SNIPPET: example -->
* </pre>
- *
* <pre>
* <!-- START SNIPPET: example2 -->
* Render an image submit:
* <s:submit type="image" value="%{'Submit'}" label="Submit the form" src="submit.gif"/>
* <!-- END SNIPPET: example2 -->
* </pre>
- *
* <pre>
* <!-- START SNIPPET: example3 -->
* Render an button submit:
@@ -65,24 +62,34 @@
* <!-- START SNIPPET: ajaxJavadoc -->
* <B>THE FOLLOWING IS ONLY VALID WHEN AJAX IS CONFIGURED</B>
* <ul>
- * <li>resultDivId</li>
- * <li>notifyTopics</li>
- * <li>onLoadJS</li>
- * <li>preInvokeJS</li>
+ * <li>href</li>
+ * <li>errorText</li>
+ * <li>afterLoading</li>
+ * <li>beforeLoading</li>
+ * <li>executeScripts</li>
+ * <li>loadingText</li>
+ * <li>refreshListenTopic</li>
+ * <li>handler</li>
+ * <li>formId</li>
+ * <li>formFilter</li>
+ * <li>targets</li>
* </ul>
- * The remote form has three basic modes of use, using the resultDivId,
- * the notifyTopics, or the onLoadJS. You can mix and match any combination of
- * them to get your desired result. All of these examples are contained in the
- * Ajax example webapp. Lets go through some scenarios to see how you might use it:
- * <!-- END SNIPPET: ajaxJavadoc -->
- *
- * <!-- START SNIPPET: ajxExDescription1 -->
- * Show the results in another div. If you want your results to be shown in
- * a div, use the resultDivId where the id is the id of the div you want them
- * shown in. This is an inner HTML approah. Your results get jammed into
- * the div for you. Here is a sample of this approach:
- * <!-- END SNIPPET: ajxExDescription1 -->
- *
+ * '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/>
+ * '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/>
+ * 'handler' is the name of the function that will take care of making the AJAX request. Dojo's widget
+ * and dom node are passed as parameters).<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/>
+ * 'refreshListenTopic' is the topic that forces an update
* <pre>
* <!-- START SNIPPET: ajxExample1 -->
* Remote form replacing another div:
@@ -101,66 +108,6 @@
* <!-- END SNIPPET: ajxExample1 -->
* </pre>
*
- *
- * <!-- START SNIPPET: ajxExDescription2 -->
- * Notify other controls(divs) of a change. Using an pub-sub model you can
- * notify others that your control changed and they can take the appropriate action.
- * Most likely they will execute some action to refresh. The notifyTopics does this
- * for you. You can have many topic names in a comma delimited list.
- * eg: notifyTopics="newPerson, dataChanged" .
- * Here is an example of this approach:
- * <!-- END SNIPPET: ajxExDescription2 -->
- *
- * <pre>
- * <!-- START SNIPPET: ajxExample2 -->
- * <s:form id="frm1" action="newPersonWithXMLResult" theme="ajax" >
- * <s:textfield label="Name" name="person.name" value="person.name" size="20" required="true" />
- * <s:submit id="submitBtn" value="Save" theme="ajax" cssClass="primary" notifyTopics="personUpdated, systemWorking" />
- * </s:form >
- *
- * <s:div href="/listPeople.action" theme="ajax" errorText="error opps"
- * loadingText="loading..." id="cart-body" >
- * <s:action namespace="" name="listPeople" executeResult="true" />
- * </s:div>
- * <!-- END SNIPPET: ajxExample2 -->
- * </pre>
- *
- * <!-- START SNIPPET: ajxExDescription3 -->
- * Massage the results with JavaScript. Say that your result returns some h
- * appy XML and you want to parse it and do lots of cool things with it.
- * The way to do this is with a onLoadJS handler. Here you provide the name of
- * a JavaScript function to be called back with the result and the event type.
- * The only key is that you must use the variable names 'data' and 'type' when
- * defining the callback. For example: onLoadJS="myFancyDancyFunction(data, type)".
- * While I talked about XML in this example, your not limited to XML, the data in
- * the callback will be exactly whats returned as your result.
- * Here is an example of this approach:
- * <!-- END SNIPPET: ajxExDescription3 -->
- *
- * <pre>
- * <!-- START SNIPPET: ajxExample3 -->
- * <script language="JavaScript" type="text/javascript">
- * function doGreatThings(data, type) {
- * //Do whatever with your returned fragment...
- * //Perhapps.... if xml...
- * var xml = dojo.xml.domUtil.createDocumentFromText(data);
- * var people = xml.getElementsByTagName("person");
- * for(var i = 0;i < people.length; i ++){
- * var person = people[i];
- * var name = person.getAttribute("name")
- * var id = person.getAttribute("id")
- * alert('Thanks dude. Person: ' + name + ' saved great!!!');
- * }
- *
- * }
- * </script>
- *
- * <s:form id="frm1" action="newPersonWithXMLResult" theme="ajax" >
- * <s:textfield label="Name" name="person.name" value="person.name" size="20" required="true" />
- * <s:submit id="submitBtn" value="Save" theme="ajax" cssClass="primary" onLoadJS="doGreatThings(data, type)" />
- * </s:form>
- * <!-- END SNIPPET: ajxExample3 -->
- * </pre>
*
* @s.tag name="submit" tld-body-content="JSP" tld-tag-class="org.apache.struts2.views.jsp.ui.SubmitTag"
* description="Render a submit button"
Modified: struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/TabbedPanel.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/TabbedPanel.java?view=diff&rev=475814&r1=475813&r2=475814
==============================================================================
--- struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/TabbedPanel.java (original)
+++ struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/TabbedPanel.java Thu Nov 16 08:58:57 2006
@@ -38,54 +38,20 @@
* <!-- END SNIPPET: exdesc -->
* <pre>
* <!-- START SNIPPET: example -->
- * <s:tabbedPanel id="test2" theme="simple" >
- * <s:panel id="left" tabName="left" theme="ajax">
- * This is the left pane<br/>
- * <s:form >
- * <s:textfield name="tt" label="Test Text" /> <br/>
- * <s:textfield name="tt2" label="Test Text2" />
- * </s:form>
- * </s:panel>
- * <s:panel remote="true" href="/AjaxTest.action" id="ryh1" theme="ajax" tabName="remote one" />
- * <s:panel id="middle" tabName="middle" theme="ajax">
- * middle tab<br/>
- * <s:form >
- * <s:textfield name="tt" label="Test Text44" /> <br/>
- * <s:textfield name="tt2" label="Test Text442" />
- * </s:form>
- * </s:panel>
- * <s:panel remote="true" href="/AjaxTest.action" id="ryh21" theme="ajax" tabName="remote right" />
- * </s:tabbedPanel>
+ * <s:tabbedPanel id="test" >
+ * <s:div id="one" label="one" theme="ajax" labelposition="top" >
+ * This is the first pane<br/>
+ * <s:form>
+ * <s:textfield name="tt" label="Test Text"/> <br/>
+ * <s:textfield name="tt2" label="Test Text2"/>
+ * </s:form>
+ * </s:div>
+ * <s:div id="three" label="remote" theme="ajax" href="/AjaxTest.action" >
+ * This is the remote tab
+ * </s:div>
+ *</s:tabbedPanel>
* <!-- END SNIPPET: example -->
* </pre>
- *
- * <p/> <b>Additional Configuration</b>
- *
- * <!-- START SNIPPET: exdesc2 -->
- * If you are looking for the "nifty" rounded corner look, there is additional configuration. This assumes
- * that the background color of the tabs is white. If you are using a different color, please modify the
- * parameter in the Rounded() method.<p/>
- * <!-- END SNIPPET: exdesc2 -->
- *
- * <pre>
- * <!-- START SNIPPET: example2 -->
- * <link rel="stylesheet" type="text/css" href="<s:url value="/struts/tabs.css"/>">
- * <link rel="stylesheet" type="text/css" href="<s:url value="/struts/niftycorners/niftyCorners.css"/>">
- * <link rel="stylesheet" type="text/css" href="<s:url value="/struts/niftycorners/niftyPrint.css"/>" media="print">
- * <script type="text/javascript" src="<s:url value="/struts/niftycorners/nifty.js"/>"></script>
- * <script type="text/javascript">
- * dojo.event.connect(window, "onload", function() {
- * if (!NiftyCheck())
- * return;
- * Rounded("li.tab_selected", "top", "white", "transparent", "border #ffffffS");
- * Rounded("li.tab_unselected", "top", "white", "transparent", "border #ffffffS");
- * // "white" needs to be replaced with the background color
- * });
- * </script>
- * <!-- END SNIPPET: example2 -->
- * </pre>
- *
- * <b>Important:</b> Be sure to setup the page containing this tag to be Configured for AJAX
*
* @s.tag name="tabbedPanel" tld-body-content="JSP" tld-tag-class="org.apache.struts2.views.jsp.ui.TabbedPanelTag"
* description="Render a tabbedPanel widget."
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=475814&r1=475813&r2=475814
==============================================================================
--- 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 Thu Nov 16 08:58:57 2006
@@ -26,6 +26,7 @@
formId : "",
formFilter : "",
+ formNode : null,
event : "",
@@ -52,6 +53,12 @@
if(!dojo.string.isBlank(this.event)) {
dojo.event.connect(this.domNode, this.event, this, "reloadContents");
}
+ if(dojo.string.isBlank(this.href)) {
+ this.formNode = dojo.string.isBlank(this.formId) ? dojo.dom.getFirstAncestorByTag(this.domNode, "form") : dojo.byId(this.formId);
+ this.href = this.formNode.action;
+ } else {
+ this.formNode = dojo.byId(this.formId);
+ }
},
log : function(text) {
@@ -107,13 +114,12 @@
}
try {
var self = this;
-
this.setContent(this.loadingText);
dojo.io.bind({
- url: this.href,
+ url: self.href,
useCache: false,
preventCache: true,
- formNode: dojo.byId(self.formId),
+ formNode: self.formNode,
formFilter: window[self.formFilter],
handler: function(type, data, e) {
dojo.lang.hitch(self, "bindHandler")(type, data, e);
Modified: struts/struts2/trunk/core/src/main/resources/template/ajax/form.ftl
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/resources/template/ajax/form.ftl?view=diff&rev=475814&r1=475813&r2=475814
==============================================================================
--- struts/struts2/trunk/core/src/main/resources/template/ajax/form.ftl (original)
+++ struts/struts2/trunk/core/src/main/resources/template/ajax/form.ftl Thu Nov 16 08:58:57 2006
@@ -37,7 +37,6 @@
style="${parameters.cssStyle?html}"<#rt/>
</#if>
${tag.addParameter("ajaxSubmit", "true")}
- onSubmit="return isAjaxFormSubmit(this);"
>
<#include "/${parameters.templateDir}/${themeProperties.parent}/control.ftl" />
<#--