WW-1607 Separate dojo-related tags into their own plugin

* Overwrite parent attribute setters so they are added to the TLD

git-svn-id: https://svn.apache.org/repos/asf/struts/struts2/trunk@514458 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Musachy Barroso
2007-03-04 18:51:30 +00:00
parent e2f349dca9
commit de09c2ca53
19 changed files with 173 additions and 205 deletions
+6
View File
@@ -37,6 +37,12 @@
<artifactId>struts2-struts1-plugin</artifactId>
<version>${pom.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
<artifactId>struts2-dojo-plugin</artifactId>
<version>${pom.version}</version>
</dependency>
<dependency>
<groupId>org.apache.struts</groupId>
@@ -1,5 +1,5 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<html>
<head>
<title>Ajax Examples</title>
@@ -16,7 +16,7 @@
Using a JSON list returned from an action (href="/JSONList.action"), without autoComplete (autoComplete="false"), use indicator, search substring (searchType="substring")
<br/>
<s:autocompleter name="state" theme="ajax" indicator="indicator1" href="%{jsonList}" cssStyle="width: 200px;" autoComplete="false" searchType="substring"/>
<sx:autocompleter name="state" indicator="indicator1" href="%{jsonList}" cssStyle="width: 200px;" autoComplete="false" searchType="substring"/>
<img id="indicator1" src="${pageContext.request.contextPath}/images/indicator.gif" alt="Loading..." style="display:none"/>
<br/>
@@ -24,7 +24,7 @@ Using a JSON list returned from an action (href="/JSONList.action"), without aut
Reload on type (loadOnTextChange="true"), after 3 characters (loadMinimumCout="3", it is "3" by default), without the down arrow button (showDownArrow="false")
<br/>
<s:autocompleter theme="ajax" indicator="indicator" href="%{jsonList}" cssStyle="width: 200px;" autoComplete="false" loadOnTextChange="true" loadMinimumCount="3" showDownArrow="false"/>
<sx:autocompleter indicator="indicator" href="%{jsonList}" cssStyle="width: 200px;" autoComplete="false" loadOnTextChange="true" loadMinimumCount="3" showDownArrow="false"/>
<img id="indicator" src="${pageContext.request.contextPath}/images/indicator.gif" alt="Loading..." style="display:none"/>
<br/>
@@ -32,35 +32,35 @@ Reload on type (loadOnTextChange="true"), after 3 characters (loadMinimumCout="3
Using a JSON list returned from an action (href="/JSONList.action"), with autoComplete (autoComplete="true")
<br/>
<s:autocompleter theme="ajax" href="%{jsonList}" cssStyle="width: 200px;" autoComplete="true" />
<sx:autocompleter href="%{jsonList}" cssStyle="width: 200px;" autoComplete="true" />
<br/>
<br/>
Using a local list (list="{'apple','banana','grape','pear'}")
<br/>
<s:autocompleter theme="simple" list="{'apple','banana','grape','pear'}" cssStyle="width: 150px;"/>
<sx:autocompleter list="{'apple','banana','grape','pear'}" cssStyle="width: 150px;"/>
<br/>
<br/>
Force valid options (forceValidOption="true")
<br/>
<s:autocompleter theme="ajax" href="%{jsonList}" cssStyle="width: 200px;" forceValidOption="true"/>
<sx:autocompleter href="%{jsonList}" cssStyle="width: 200px;" forceValidOption="true"/>
<br/>
<br/>
Make dropdown's height to 180px (dropdownHeight="180")
<br/>
<s:autocompleter theme="ajax" href="%{jsonList}" cssStyle="width: 200px;" dropdownHeight="180"/>
<sx:autocompleter href="%{jsonList}" cssStyle="width: 200px;" dropdownHeight="180"/>
<br/>
<br/>
Disabled combobox (disabled="true")
<br/>
<s:autocompleter theme="ajax" href="%{jsonList}" cssStyle="width: 200px;" disabled="true"/>
<sx:autocompleter href="%{jsonList}" cssStyle="width: 200px;" disabled="true"/>
<br/>
<br/>
@@ -71,9 +71,9 @@ Disabled combobox (disabled="true")
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" notifyTopics="/Changed" forceValidOption="true" id="sel"/></p>
<p>Autocompleter 1 <sx:autocompleter 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" listenTopics="/Changed" forceValidOption="true" id="ops"/>
Autocompleter 2 <sx:autocompleter href="%{#autoex}" autoComplete="false" formId="selectForm" listenTopics="/Changed" forceValidOption="true" id="ops"/>
<br/>
<br/>
@@ -1,4 +1,4 @@
<%@ taglib prefix="s" uri="/struts-tags" %>
<!--// START SNIPPET: common-include-->
<s:head theme="ajax"/>
<s:head theme="ajax" debug="true"/>
<!--// END SNIPPET: common-include-->
@@ -1,5 +1,5 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>
<html>
<head>
@@ -33,19 +33,19 @@
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"/>
<sx:submit type="submit" value="submit" targets="t1" href="%{ajaxTest}" 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"/>
<sx:submit type="submit" value="submit" targets="t1" href="%{ajaxTest}" notifyTopics="/after"/>
<br/><br/>
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}" align="left" />
<sx:submit type="image" label="Alt Text" targets="t1"
src="${pageContext.request.contextPath}/images/struts-power.gif" href="%{ajaxTest}" />
<br/><br/>
<label for="textInput">Text to be echoed</label>
@@ -54,7 +54,7 @@ Use an image as submit
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"/>
<sx:submit type="button" label="Update Content" targets="t1" id="ajaxbtn"/>
</s:form>
<br/><br/>
@@ -168,4 +168,24 @@ public abstract class AbstractRemoteCallUIBean extends ClosingUIBean implements
public void setShowLoadingText(String showLoadingText) {
this.showLoadingText = showLoadingText;
}
@StrutsTagAttribute(description="The css class to use for element")
public void setCssClass(String cssClass) {
super.setCssClass(cssClass);
}
@StrutsTagAttribute(description="The css style to use for element")
public void setCssStyle(String cssStyle) {
super.setCssStyle(cssStyle);
}
@StrutsTagAttribute(description="The id to use for the element")
public void setId(String id) {
super.setId(id);
}
@StrutsTagAttribute(description="The name to set for element")
public void setName(String name) {
super.setName(name);
}
}
@@ -33,53 +33,7 @@ import com.opensymphony.xwork2.util.ValueStack;
*
* A tag that creates a HTML &lt;a href='' /&gt; that when clicked calls a URL remote XMLHttpRequest call via the dojo
* framework.<p/>
*
* <!-- START SNIPPET: ajaxJavadoc -->
* <B>THE FOLLOWING IS ONLY VALID WHEN AJAX IS CONFIGURED</B>
* <ul>
* <li>href</li>
* <li>errorText</li>
* <li>listenTopics</li>
* <li>notifyTopics</li>
* <li>executeScripts</li>
* <li>loadingText</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/>
* '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/>
* '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/>
* '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>
* 'showLoadingText' show loading text 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 -->
*
*<!-- END SNIPPET: javadoc -->
* <p/> <b>Examples</b>
*
* <pre>
@@ -34,50 +34,7 @@ import com.opensymphony.xwork2.util.ValueStack;
* <p>The autocomplete tag is a combobox that can autocomplete text entered on the input box.
* When used on the "simple" theme, the autocompleter can be used like the ComboBox.
* When used on the "ajax" theme, the list can be retieved from an action. </p>
* <!-- END SNIPPET: javadoc -->
* <!-- START SNIPPET: ajaxJavadoc -->
* <B>THE FOLLOWING IS ONLY VALID WHEN AJAX IS CONFIGURED</B>
* <ul>
* <li>href</li>
* <li>errorText</li>
* <li>listenTopics</li>
* <li>notifyTopics</li>
* <li>listenTopics</li>
* <li>formId</li>
* <li>formFilter</li>
* <li>indicator</li>
* <li>loadOnTextChange</li>
* <li>loadMinimumCount</li>
* <li>showDownArrow</li>
* <li>searchType</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/>
* 'loadOnTextChange' options will be reloaded everytime a character is typed on the textbox<p/>
* 'loadMinimumCount' minimum number of characters that will force the content to be loaded<p/>
* 'showDownError' show or hide the down arrow button<p/>
* 'searchType' how the search must be performed, options are: "startstring", "startword" and "substring"<p/>
* 'keyName' name of the field to which the selected key will be assigned<p/>
* 'iconPath' path of icon used for the dropdown<p/>
* 'templateCssPath' path to css file used to customize Dojo's widget<p/>
* 'dataFieldName' name of the field to be used as the list in the returned JSON string<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>
*<!-- END SNIPPET: ajaxJavadoc -->
*<!-- END SNIPPET: javadoc -->
*
*<!-- START SNIPPET: example -->
*<p>Autocompleter that gets its list from an action:</p>
@@ -299,4 +256,29 @@ public class Autocompleter extends ComboBox {
public void setDataFieldName(String dataFieldName) {
this.dataFieldName = dataFieldName;
}
@StrutsTagAttribute(description="The css class to use for element")
public void setCssClass(String cssClass) {
super.setCssClass(cssClass);
}
@StrutsTagAttribute(description="The css style to use for element")
public void setCssStyle(String cssStyle) {
super.setCssStyle(cssStyle);
}
@StrutsTagAttribute(description="The id to use for the element")
public void setId(String id) {
super.setId(id);
}
@StrutsTagAttribute(description="The name to set for element")
public void setName(String name) {
super.setName(name);
}
@StrutsTagAttribute(description="Preset the value of input element")
public void setValue(String arg0) {
super.setValue(arg0);
}
}
@@ -291,6 +291,11 @@ public class DateTimePicker extends UIBean {
this.templateCssPath = templateCssPath;
}
@StrutsTagAttribute(description="Preset the value of input element")
public void setValue(String arg0) {
super.setValue(arg0);
}
private String format(Object obj) {
if(obj == null)
return null;
@@ -37,54 +37,7 @@ import com.opensymphony.xwork2.util.ValueStack;
* the dojo framework.
* </p>
* <div>
* <!-- 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>executeScripts</li>
* <li>loadingText</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' 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/>
* '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/>
* 'updateFreq' sets(in milliseconds) the update interval.<p/>
* 'autoStart' if set to true(true by default) starts the timer automatically<p/>
* 'startTimerListenTopics' is a comma-separated list of topics used to start the timer<p/>
* 'stopTimerListenTopics' is a comma-separated list of topics used to stop the timer<p/>
* 'listenTopics' comma separated list of topics names, that will trigger a request<p/>
* 'indicator' element to be shown while the request executing<p/>
* 'showErrorTransportText': whether errors should be displayed (on 'targets')</p>
* 'showLoadingText' show loading text on targets</p>
* 'separateScript' Run scripts in a separate scope, unique for each Div<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 -->
*
* </div><p> <b>Examples</b>
*
* <pre>
@@ -50,5 +50,10 @@ public interface RemoteUICallBean {
void setShowLoadingText(String showLoadingText);
void setIndicator(String indicator);
void setName(String name);
void setCssStyle(String style);
void setCssClass(String cssClass);
}
@@ -65,52 +65,6 @@ import com.opensymphony.xwork2.util.ValueStack;
* <!-- END SNIPPET: example3 -->
* </pre>
*
* <!-- START SNIPPET: ajaxJavadoc -->
* <B>THE FOLLOWING IS ONLY VALID WHEN AJAX IS CONFIGURED</B>
* <ul>
* <li>href</li>
* <li>errorText</li>
* <li>listenTopics</li>
* <li>notifyTopics</li>
* <li>executeScripts</li>
* <li>loadingText</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/>
* '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/>
* '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/>
* '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>
* 'showLoadingText' show loading text 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: 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
@@ -315,7 +269,6 @@ public class Submit extends FormButton implements RemoteUICallBean {
this.targets = targets;
}
@StrutsTagAttribute(description="Topics that will published when the remote call completes")
public void setNotifyTopics(String notifyTopics) {
this.notifyTopics = notifyTopics;
@@ -327,7 +280,6 @@ public class Submit extends FormButton implements RemoteUICallBean {
this.showErrorTransportText = showErrorTransportText;
}
@StrutsTagAttribute(description="Set indicator")
public void setIndicator(String indicator) {
this.indicator = indicator;
@@ -337,4 +289,40 @@ public class Submit extends FormButton implements RemoteUICallBean {
public void setShowLoadingText(String showLoadingText) {
this.showLoadingText = showLoadingText;
}
@StrutsTagAttribute(description="The css class to use for element")
public void setCssClass(String cssClass) {
super.setCssClass(cssClass);
}
@StrutsTagAttribute(description="The css style to use for element")
public void setCssStyle(String cssStyle) {
super.setCssStyle(cssStyle);
}
@StrutsTagAttribute(description="The id to use for the element")
public void setId(String id) {
super.setId(id);
}
@StrutsTagAttribute(description="The name to set for element")
public void setName(String name) {
super.setName(name);
}
@StrutsTagAttribute(description="The type of submit to use. Valid values are <i>input</i>, " +
"<i>button</i> and <i>image</i>.", defaultValue="input")
public void setType(String type) {
super.setType(type);
}
@StrutsTagAttribute(description="Preset the value of input element.")
public void setValue(String value) {
super.setValue(value);
}
@StrutsTagAttribute(description="Label expression used for rendering a element specific label")
public void setLabel(String label) {
super.setLabel(label);
}
}
@@ -431,5 +431,25 @@ public class Tree extends ClosingUIBean {
public void setShowGrid(String showGrid) {
this.showGrid = showGrid;
}
@StrutsTagAttribute(description="The css class to use for element")
public void setCssClass(String cssClass) {
super.setCssClass(cssClass);
}
@StrutsTagAttribute(description="The css style to use for element")
public void setCssStyle(String cssStyle) {
super.setCssStyle(cssStyle);
}
@StrutsTagAttribute(description="The id to use for the element")
public void setId(String id) {
super.setId(id);
}
@StrutsTagAttribute(description="The name to set for element")
public void setName(String name) {
super.setName(name);
}
}
@@ -102,4 +102,24 @@ public class TreeNode extends ClosingUIBean {
public void setLabel(String label) {
super.setLabel(label);
}
@StrutsTagAttribute(description="The css class to use for element")
public void setCssClass(String cssClass) {
super.setCssClass(cssClass);
}
@StrutsTagAttribute(description="The css style to use for element")
public void setCssStyle(String cssStyle) {
super.setCssStyle(cssStyle);
}
@StrutsTagAttribute(description="The id to use for the element")
public void setId(String id) {
super.setId(id);
}
@StrutsTagAttribute(description="The name to set for element")
public void setName(String name) {
super.setName(name);
}
}
@@ -21,6 +21,7 @@
package org.apache.struts2.views.jsp.ui;
import org.apache.struts2.TestAction;
import org.apache.struts2.views.jsp.ui.dojo.AnchorTag;
/**
@@ -20,6 +20,8 @@
*/
package org.apache.struts2.views.jsp.ui;
import org.apache.struts2.views.jsp.ui.dojo.AutocompleterTag;
/**
* @see org.apache.struts2.components.Autocompleter
@@ -20,6 +20,10 @@
*/
package org.apache.struts2.views.jsp.ui;
import org.apache.struts2.views.jsp.ui.dojo.AbstractRemoteCallUITag;
import org.apache.struts2.views.jsp.ui.dojo.DateTimePickerTag;
import org.apache.struts2.views.jsp.ui.dojo.DivTag;
/**
@@ -21,6 +21,8 @@
package org.apache.struts2.views.jsp.ui;
import org.apache.struts2.TestAction;
import org.apache.struts2.views.jsp.ui.dojo.AbstractRemoteCallUITag;
import org.apache.struts2.views.jsp.ui.dojo.DivTag;
/**
@@ -18,6 +18,9 @@
package org.apache.struts2.views.jsp.ui;
import org.apache.struts2.TestAction;
import org.apache.struts2.views.jsp.ui.dojo.AbstractRemoteCallUITag;
import org.apache.struts2.views.jsp.ui.dojo.DivTag;
import org.apache.struts2.views.jsp.ui.dojo.SubmitTag;
/**
* Test Submit component in "ajax" theme.
@@ -21,6 +21,9 @@
package org.apache.struts2.views.jsp.ui;
import org.apache.struts2.views.jsp.ui.dojo.TreeNodeTag;
import org.apache.struts2.views.jsp.ui.dojo.TreeTag;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;