diff --git a/plugins/dojo/pom.xml b/plugins/dojo/pom.xml new file mode 100644 index 000000000..7f7de242b --- /dev/null +++ b/plugins/dojo/pom.xml @@ -0,0 +1,198 @@ + + + + struts2-plugins + org.apache.struts + 2.1.0-SNAPSHOT + + 4.0.0 + org.apache.struts + struts2-dojo-plugin + Struts2 Dojo Plugin + + + + scm:svn:http://svn.apache.org/repos/asf/struts/struts2/trunk/plugins/dojo/ + + + scm:svn:https://svn.apache.org/repos/asf/struts/struts2/trunk/plugins/dojo/ + + + http://svn.apache.org/viewcvs.cgi/struts/struts2/trunk/plugins/dojo/ + + + + + + + org.apache.myfaces.tobago + maven-apt-plugin + + + uri=/struts-dojo-tags,tlibVersion=2.2.3,jspVersion=1.2,shortName=sx,displayName="Struts + Dojo Tags", + outFile=${basedir}/target/classes/META-INF/struts-dojo-tags.tld, + description="Struts AJAX tags based on Dojo.", + outTemplatesDir=${basedir}/../../core/src/site/resources/tags/ajax + + target + false + true + true + true + + org.apache.struts.annotations.taglib.apt.TLDAnnotationProcessorFactory + + 1.5 + + **/*.java + + + + + compile + + execute + + + + + + + + + + + org.apache.struts + struts2-core + ${pom.version} + + + + + javax.servlet + jsp-api + 2.0 + provided + + + + + velocity + velocity + 1.4 + true + + + + + junit + junit + compile + 3.8.1 + + true + + + + org.testng + testng + 5.1 + true + jdk15 + + + + jmock + jmock + 1.0.1 + test + + + org.easymock + easymock + 2.0 + test + + + + + jmock + jmock-cglib + 1.0.1 + test + + + + mockobjects + mockobjects-core + 0.09 + test + + + + mockobjects + mockobjects-jdk1.3 + 0.09 + test + + + + mockobjects + mockobjects-alt-jdk1.3 + 0.09 + test + + + + mockobjects + mockobjects-alt-jdk1.3-j2ee1.3 + 0.09 + test + + + + mockobjects + mockobjects-jdk1.3-j2ee1.3 + 0.09 + test + + + + + + org.springframework + spring-mock + 1.2.8 + true + + + + org.springframework + spring-core + 1.2.8 + test + + + + + org.apache.struts + struts-annotations + 1.0.2-SNAPSHOT + true + + + \ No newline at end of file diff --git a/plugins/dojo/src/main/java/org/apache/struts2/components/AbstractRemoteCallUIBean.java b/plugins/dojo/src/main/java/org/apache/struts2/components/AbstractRemoteCallUIBean.java new file mode 100644 index 000000000..4cf5313c1 --- /dev/null +++ b/plugins/dojo/src/main/java/org/apache/struts2/components/AbstractRemoteCallUIBean.java @@ -0,0 +1,171 @@ +/* + * $Id: AbstractRemoteCallUIBean.java 508285 2007-02-16 02:42:24Z musachy $ + * + * Copyright 2006 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.struts2.components; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts2.views.annotations.StrutsTagAttribute; +import org.apache.struts2.views.annotations.StrutsTagSkipInheritance; + +import com.opensymphony.xwork2.util.ValueStack; + +/** + * AbstractRemoteCallUIBean is superclass for all components dealing with remote + * calls. + */ +@StrutsTagSkipInheritance +public abstract class AbstractRemoteCallUIBean extends ClosingUIBean implements RemoteUICallBean { + + protected String href; + protected String errorText; + protected String afterLoading; + protected String beforeLoading; + protected String executeScripts; + protected String loadingText; + protected String listenTopics; + protected String handler; + protected String formId; + protected String formFilter; + protected String notifyTopics; + protected String showErrorTransportText; + protected String indicator; + protected String showLoadingText; + + public AbstractRemoteCallUIBean(ValueStack stack, HttpServletRequest request, + HttpServletResponse response) { + super(stack, request, response); + } + + public void evaluateExtraParams() { + super.evaluateExtraParams(); + + if (href != null) + addParameter("href", findString(href)); + if (errorText != null) + addParameter("errorText", findString(errorText)); + if (loadingText != null) + addParameter("loadingText", findString(loadingText)); + if (afterLoading != null) + addParameter("afterLoading", findString(afterLoading)); + if (beforeLoading != null) + addParameter("beforeLoading", findString(beforeLoading)); + if (executeScripts != null) + addParameter("executeScripts", findValue(executeScripts, Boolean.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); + if (showLoadingText != null) + addParameter("showLoadingText", findString(showLoadingText)); + } + + + @StrutsTagAttribute(description="Topic that will trigger the remote call") + public void setListenTopics(String listenTopics) { + this.listenTopics = listenTopics; + } + + @StrutsTagAttribute(description="The URL to call to obtain the content. Note: If used with ajax context, the value must be set as an url tag value.") + public void setHref(String href) { + this.href = href; + } + + + @StrutsTagAttribute(description="The text to display to the user if the is an error fetching the content") + public void setErrorText(String errorText) { + this.errorText = errorText; + } + + + /* (non-Javadoc) + * @see org.apache.struts2.components.RemoteUICallBean#setAfterLoading(java.lang.String) + */ + public void setAfterLoading(String afterLoading) { + this.afterLoading = afterLoading; + } + + + /* (non-Javadoc) + * @see org.apache.struts2.components.RemoteUICallBean#setBeforeLoading(java.lang.String) + */ + public void setBeforeLoading(String beforeLoading) { + this.beforeLoading = beforeLoading; + } + + + @StrutsTagAttribute(description="Javascript code in the fetched content will be executed", type="Boolean", defaultValue="false") + public void setExecuteScripts(String executeScripts) { + this.executeScripts = executeScripts; + } + + @StrutsTagAttribute(description="Text to be shown while content is being fetched", defaultValue="Loading...") + public void setLoadingText(String loadingText) { + this.loadingText = loadingText; + } + + + @StrutsTagAttribute(description="Javascript function name that will make the request") + public void setHandler(String handler) { + this.handler = handler; + } + + + @StrutsTagAttribute(description="Function name used to filter the fields of the form.") + public void setFormFilter(String formFilter) { + this.formFilter = formFilter; + } + + @StrutsTagAttribute(description="Form id whose fields will be serialized and passed as parameters") + public void setFormId(String formId) { + this.formId = formId; + } + + @StrutsTagAttribute(description="Topics that will published when the remote call completes") + public void setNotifyTopics(String notifyTopics) { + this.notifyTopics = notifyTopics; + } + + + @StrutsTagAttribute(description="Set whether errors will be shown or not", type="Boolean", defaultValue="true") + public void setShowErrorTransportText(String showError) { + this.showErrorTransportText = showError; + } + + @StrutsTagAttribute(description="Id of element that will be shown while making request") + public void setIndicator(String indicator) { + this.indicator = indicator; + } + + @StrutsTagAttribute(description="Show loading text on targets", type="Boolean", defaultValue="true") + public void setShowLoadingText(String showLoadingText) { + this.showLoadingText = showLoadingText; + } +} diff --git a/plugins/dojo/src/main/java/org/apache/struts2/components/Anchor.java b/plugins/dojo/src/main/java/org/apache/struts2/components/Anchor.java new file mode 100644 index 000000000..0354114b3 --- /dev/null +++ b/plugins/dojo/src/main/java/org/apache/struts2/components/Anchor.java @@ -0,0 +1,171 @@ +/* + * $Id: Anchor.java 508285 2007-02-16 02:42:24Z musachy $ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts2.components; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts2.views.annotations.StrutsTag; +import org.apache.struts2.views.annotations.StrutsTagAttribute; + +import com.opensymphony.xwork2.util.ValueStack; + +/** + * + * + * A tag that creates a HTML <a href='' /> that when clicked calls a URL remote XMLHttpRequest call via the dojo + * framework.

+ * + * + * THE FOLLOWING IS ONLY VALID WHEN AJAX IS CONFIGURED + *

+ * 'resultDivId' Deprecated. Use targets.

+ * 'targets' is a list of element ids whose content will be updated with the + * text returned from request.

+ * 'errorText' is the text that will be displayed when there is an error making the request.

+ * 'onLoadJS' Deprecated. Use 'notifyTopics'.

+ * 'preInvokeJS' Deprecated. Use 'notifyTopics'.

+ * 'executeScripts' if set to true will execute javascript sections in the returned text.

+ * 'loadingText' is the text that will be displayed on the 'targets' elements while making the + * request.

+ * '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).

+ * 'formId' is the id of the html form whose fields will be seralized and passed as parameters + * in the request.

+ * '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.

+ * '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')

+ * 'showLoadingText' show loading text on targets

+ * 'notifyTopics' comma separated list of topics names, that will be published. Three parameters are passed:

+ *

+ * + * + *

Examples + * + *

+ * 
+ * <s:a id="link1" theme="ajax" href="/DoIt.action" errorText="An error ocurred" loadingText="Loading...">
+ *     <img border="none" src="<%=request.getContextPath()%>/images/delete.gif"/>
+ *     <s:param name="id" value="1"/>
+ * </s:a>
+ * 
+ * 
+ * + *

+ * + * + * + * Results in + * + * + * + *

+ * + *
+ * 
+ * <a dojoType="BindAnchor" executeScripts="true" id="link1" href="/DoIt.action?id=1" errorText="An error ocurred"></a>
+ * 
+ * 
+ * + *

+ * + * + * + * Here is an example that uses the beforeLoading. This example is in altSyntax=true: + * + * + * + *

+ * + *
+ * 
+ * <s:a id="test" theme="ajax" href="/simpeResult.action" beforeLoading="confirm('Are you sure?')">
+ *  A
+ * </s:a>
+ * 
+ * 
+ * + */ +@StrutsTag(name="a", tldTagClass="org.apache.struts2.views.jsp.ui.AnchorTag", description="Render a HTML href element that when clicked can optionally call a URL via remote XMLHttpRequest and updates its targets") +public class Anchor extends AbstractRemoteCallUIBean { + 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; + + public Anchor(ValueStack stack, HttpServletRequest request, HttpServletResponse response) { + super(stack, request, response); + } + + public String getDefaultOpenTemplate() { + return OPEN_TEMPLATE; + } + + protected String getDefaultTemplate() { + return TEMPLATE; + } + + public void evaluateExtraParams() { + super.evaluateExtraParams(); + + if(targets != null) + addParameter("targets", findString(targets)); + } + + @StrutsTagAttribute(description="Comma delimited list of ids of the elements whose content will be updated") + public void setTargets(String targets) { + this.targets = targets; + } + + @StrutsTagAttribute(name="onLoadJS", description="Deprecated. Use 'notifyTopics'. Javascript code execute after reload") + public void setAfterLoading(String afterLoading) { + this.afterLoading = afterLoading; + } + + + @StrutsTagAttribute(name="preInvokeJS", description="Deprecated. Use 'notifyTopics'. Javascript code execute before reload") + public void setBeforeLoading(String beforeLoading) { + this.beforeLoading = beforeLoading; + } +} diff --git a/plugins/dojo/src/main/java/org/apache/struts2/components/Autocompleter.java b/plugins/dojo/src/main/java/org/apache/struts2/components/Autocompleter.java new file mode 100644 index 000000000..d63522dcc --- /dev/null +++ b/plugins/dojo/src/main/java/org/apache/struts2/components/Autocompleter.java @@ -0,0 +1,302 @@ +/* + * $Id: Autocompleter.java 510785 2007-02-23 03:05:33Z musachy $ + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.struts2.components; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.apache.struts2.views.annotations.StrutsTag; +import org.apache.struts2.views.annotations.StrutsTagAttribute; +import org.apache.struts2.views.annotations.StrutsTagSkipInheritance; + +import com.opensymphony.xwork2.util.ValueStack; + +/** + * + *

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.

+ * + * + * THE FOLLOWING IS ONLY VALID WHEN AJAX IS CONFIGURED + * + * 'dropdownWidth' width in pixels of the drodpdown, same as autocompleter's width by default

+ * 'dropdownHeight' height in pixels of the drodown, 120 px by default

+ * 'forceValidOption' if invalid option is selected, clear autocompleter's text when focus is lost

+ * 'autoComplete', if true, make suggestions on the textbox

+ * 'formId' is the id of the html form whose fields will be seralized and passed as parameters + * in the request.

+ * '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.

+ * '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')

+ * 'loadOnTextChange' options will be reloaded everytime a character is typed on the textbox

+ * 'loadMinimumCount' minimum number of characters that will force the content to be loaded

+ * 'showDownError' show or hide the down arrow button

+ * 'searchType' how the search must be performed, options are: "startstring", "startword" and "substring"

+ * 'keyName' name of the field to which the selected key will be assigned

+ * 'iconPath' path of icon used for the dropdown

+ * 'templateCssPath' path to css file used to customize Dojo's widget

+ * 'dataFieldName' name of the field to be used as the list in the returned JSON string

+ * 'notifyTopics' comma separated list of topics names, that will be published. Three parameters are passed:

+ *