You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by lu...@apache.org on 2015/05/22 12:59:15 UTC
[48/50] struts git commit: Moves deprecated plugins to struts-archive
repo
http://git-wip-us.apache.org/repos/asf/struts/blob/17d73d21/plugins/dojo/pom.xml
----------------------------------------------------------------------
diff --git a/plugins/dojo/pom.xml b/plugins/dojo/pom.xml
deleted file mode 100644
index abdc5b8..0000000
--- a/plugins/dojo/pom.xml
+++ /dev/null
@@ -1,240 +0,0 @@
-<?xml version="1.0"?>
-<!--
-/*
- * $Id$
- *
- * 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.
- */
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <parent>
- <artifactId>struts2-plugins</artifactId>
- <groupId>org.apache.struts</groupId>
- <version>2.5-SNAPSHOT</version>
- </parent>
-
- <modelVersion>4.0.0</modelVersion>
- <artifactId>struts2-dojo-plugin</artifactId>
- <name>Struts 2 Dojo Plugin</name>
-
- <profiles>
- <profile>
- <id>release</id>
- <activation>
- <property>
- <name>release</name>
- </property>
- </activation>
- <build>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>rat-maven-plugin</artifactId>
- <version>1.0-alpha-2</version>
- <executions>
- <execution>
- <phase>verify</phase>
- <goals>
- <goal>check</goal>
- </goals>
- <configuration>
- <addDefaultLicenseMatchers>false</addDefaultLicenseMatchers>
- <licenseMatchers>
- <classNames>
- <className>rat.analysis.license.ApacheSoftwareLicense20</className>
- </classNames>
- </licenseMatchers>
- <includes>
- <include>pom.xml</include>
- <include>src/**</include>
- </includes>
- <excludes>
- <exclude>src/main/resources/org/apache/struts2/static/dojo/nls/**</exclude>
- <exclude>src/main/resources/org/apache/struts2/static/dojo/src/**</exclude>
- <exclude>src/main/resources/org/apache/struts2/static/dojo/*</exclude>
- <exclude>src/test/resources/org/apache/struts2/dojo/views/jsp/ui/**</exclude>
- </excludes>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </profile>
- </profiles>
-
- <properties>
- <tlib.version>2.2</tlib.version>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- </properties>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.myfaces.tobago</groupId>
- <artifactId>maven-apt-plugin</artifactId>
- <version>1.0.15</version>
- <configuration>
- <A>
- uri=/struts-dojo-tags,tlibVersion=${tlib.version},jspVersion=2.0,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
- </A>
- <resourceTargetPath>target</resourceTargetPath>
- <fork>false</fork>
- <force>true</force>
- <nocompile>true</nocompile>
- <showWarnings>true</showWarnings>
- <factory>
- org.apache.struts.annotations.taglib.apt.TLDAnnotationProcessorFactory
- </factory>
- <target>1.5</target>
- <includes>
- <include>**/*.java</include>
- </includes>
- </configuration>
- <executions>
- <execution>
- <phase>compile</phase>
- <goals>
- <goal>execute</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
-
- <!-- JSP API -->
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>jsp-api</artifactId>
- <scope>provided</scope>
- </dependency>
-
- <!-- Velocity -->
- <dependency>
- <groupId>org.apache.velocity</groupId>
- <artifactId>velocity</artifactId>
- <optional>true</optional>
- </dependency>
-
- <!-- Test dependencies -->
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>struts2-junit-plugin</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>jmock</groupId>
- <artifactId>jmock</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.easymock</groupId>
- <artifactId>easymock</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>jmock</groupId>
- <artifactId>jmock-cglib</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>mockobjects</groupId>
- <artifactId>mockobjects-core</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>mockobjects</groupId>
- <artifactId>mockobjects-jdk1.3</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>mockobjects</groupId>
- <artifactId>mockobjects-alt-jdk1.3</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>mockobjects</groupId>
- <artifactId>mockobjects-alt-jdk1.3-j2ee1.3</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>mockobjects</groupId>
- <artifactId>mockobjects-jdk1.3-j2ee1.3</artifactId>
- <scope>test</scope>
- </dependency>
-
-
- <!-- Mocks for unit testing (by Spring) -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-test</artifactId>
- <scope>test</scope>
- </dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- <scope>test</scope>
- </dependency>
-
- <!-- struts-annotations must be in compile scope for maven-apt-plugin to
- function correctly. Marking it optional to exclude it from transitive
- dependency resolution -->
- <dependency>
- <groupId>org.apache.struts</groupId>
- <artifactId>struts-annotations</artifactId>
- <scope>compile</scope>
- <optional>true</optional>
- </dependency>
- </dependencies>
-
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>rat-maven-plugin</artifactId>
- <version>1.0-alpha-2</version>
- <configuration>
- <includes>
- <include>pom.xml</include>
- <include>src/**</include>
- </includes>
- <excludes>
- <exclude>src/main/resources/org/apache/struts2/static/dojo/nls/**</exclude>
- <exclude>src/main/resources/org/apache/struts2/static/dojo/src/**</exclude>
- <exclude>src/main/resources/org/apache/struts2/static/dojo/*</exclude>
- <exclude>src/test/resources/org/apache/struts2/dojo/views/jsp/ui/**</exclude>
- </excludes>
- </configuration>
- </plugin>
- </plugins>
- </reporting>
-</project>
http://git-wip-us.apache.org/repos/asf/struts/blob/17d73d21/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/AbstractRemoteBean.java
----------------------------------------------------------------------
diff --git a/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/AbstractRemoteBean.java b/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/AbstractRemoteBean.java
deleted file mode 100644
index b7e58c7..0000000
--- a/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/AbstractRemoteBean.java
+++ /dev/null
@@ -1,268 +0,0 @@
-/*
- * $Id$
- *
- * 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.dojo.components;
-
-import java.util.Random;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.struts2.components.ClosingUIBean;
-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.
- */
-public abstract class AbstractRemoteBean extends ClosingUIBean implements RemoteBean {
-
- final private static transient Random RANDOM = new Random();
-
- protected String href;
- protected String errorText;
- 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;
- protected String beforeNotifyTopics;
- protected String afterNotifyTopics;
- protected String errorNotifyTopics;
- protected String highlightColor;
- protected String highlightDuration;
- protected String separateScripts;
- protected String transport;
- protected String parseContent;
-
- public AbstractRemoteBean(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 (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));
- if (beforeNotifyTopics != null)
- addParameter("beforeNotifyTopics", findString(beforeNotifyTopics));
- if (afterNotifyTopics != null)
- addParameter("afterNotifyTopics", findString(afterNotifyTopics));
- if (errorNotifyTopics != null)
- addParameter("errorNotifyTopics", findString(errorNotifyTopics));
- if (highlightColor != null)
- addParameter("highlightColor", findString(highlightColor));
- if (highlightDuration != null)
- addParameter("highlightDuration", findString(highlightDuration));
- if (separateScripts != null)
- addParameter("separateScripts", findValue(separateScripts, Boolean.class));
- if (transport != null)
- addParameter("transport", findString(transport));
- if (parseContent != null)
- addParameter("parseContent", findValue(parseContent, Boolean.class));
- else
- addParameter("parseContent", true);
-
- // generate a random ID if not explicitly set and not parsing the content
- Boolean parseContent = (Boolean)stack.getContext().get(Head.PARSE_CONTENT);
- boolean generateId = (parseContent != null ? !parseContent : true);
-
- addParameter("pushId", generateId);
- if ((this.id == null || this.id.length() == 0) && generateId) {
- // resolves Math.abs(Integer.MIN_VALUE) issue reported by FindBugs
- // http://findbugs.sourceforge.net/bugDescriptions.html#RV_ABSOLUTE_VALUE_OF_RANDOM_INT
- int nextInt = RANDOM.nextInt();
- nextInt = nextInt == Integer.MIN_VALUE ? Integer.MAX_VALUE : Math.abs(nextInt);
- this.id = "widget_" + String.valueOf(nextInt);
- addParameter("id", this.id);
- }
- }
-
- @Override
- @StrutsTagSkipInheritance
- public void setTheme(String theme) {
- super.setTheme(theme);
- }
-
- @Override
- public String getTheme() {
- return "ajax";
- }
-
- @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;
- }
-
- @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="Comma delimmited list of topics that will published before and after the request, and on errors")
- 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="false")
- 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="Comma delimmited list of topics that will published after the request(if the request succeeds)")
- public void setAfterNotifyTopics(String afterNotifyTopics) {
- this.afterNotifyTopics = afterNotifyTopics;
- }
-
- @StrutsTagAttribute(description="Comma delimmited list of topics that will published before the request")
- public void setBeforeNotifyTopics(String beforeNotifyTopics) {
- this.beforeNotifyTopics = beforeNotifyTopics;
- }
-
- @StrutsTagAttribute(description="Comma delimmited list of topics that will published after the request(if the request fails)")
- public void setErrorNotifyTopics(String errorNotifyTopics) {
- this.errorNotifyTopics = errorNotifyTopics;
- }
-
- @StrutsTagAttribute(description = "Color used to perform a highlight effect on the elements specified in the 'targets' attribute",
- defaultValue = "none")
- public void setHighlightColor(String highlightColor) {
- this.highlightColor = highlightColor;
- }
-
- @StrutsTagAttribute(description = "Duration of highlight effect in milliseconds. Only valid if 'highlightColor' attribute is set",
- defaultValue = "2000", type="Integer")
- public void setHighlightDuration(String highlightDuration) {
- this.highlightDuration = highlightDuration;
- }
-
- @StrutsTagAttribute(description="Run scripts in a separate scope, unique for each tag", defaultValue="true")
- public void setSeparateScripts(String separateScripts) {
- this.separateScripts = separateScripts;
- }
-
- @StrutsTagAttribute(description="Transport used by Dojo to make the request", defaultValue="XMLHTTPTransport")
- public void setTransport(String transport) {
- this.transport = transport;
- }
-
- @StrutsTagAttribute(description="Parse returned HTML for Dojo widgets", defaultValue="true", type="Boolean")
- public void setParseContent(String parseContent) {
- this.parseContent = parseContent;
- }
-}
http://git-wip-us.apache.org/repos/asf/struts/blob/17d73d21/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/AbstractValidateBean.java
----------------------------------------------------------------------
diff --git a/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/AbstractValidateBean.java b/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/AbstractValidateBean.java
deleted file mode 100644
index 5bf9705..0000000
--- a/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/AbstractValidateBean.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * $Id$
- *
- * 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.dojo.components;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.struts2.components.Form;
-import org.apache.struts2.views.annotations.StrutsTagAttribute;
-
-import com.opensymphony.xwork2.util.ValueStack;
-
-/**
- * Base class for tags that perform AJAX validation
- */
-public abstract class AbstractValidateBean extends AbstractRemoteBean {
- protected String validate;
- protected String ajaxAfterValidation;
-
- public AbstractValidateBean(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
- super(stack, request, response);
- }
-
- public void evaluateExtraParams() {
- super.evaluateExtraParams();
-
- if (validate != null)
- addParameter("validate", findValue(validate, Boolean.class));
- if (ajaxAfterValidation != null)
- addParameter("ajaxAfterValidation", findValue(ajaxAfterValidation, Boolean.class));
-
- Form form = (Form) findAncestor(Form.class);
- if (form != null)
- addParameter("parentTheme", form.getTheme());
- }
-
- @StrutsTagAttribute(description = "Perform Ajax validation. 'ajaxValidation' interceptor must be applied to action", type="Boolean",
- defaultValue = "false")
- public void setValidate(String validate) {
- this.validate = validate;
- }
-
- @StrutsTagAttribute(description = "Make an asynchronous request if validation succeeds. Only valid if 'validate' is 'true'", type="Boolean",
- defaultValue = "false")
- public void setAjaxAfterValidation(String ajaxAfterValidation) {
- this.ajaxAfterValidation = ajaxAfterValidation;
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/struts/blob/17d73d21/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Anchor.java
----------------------------------------------------------------------
diff --git a/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Anchor.java b/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Anchor.java
deleted file mode 100644
index ace440e..0000000
--- a/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Anchor.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * $Id$
- *
- * 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.dojo.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;
-
-/**
- * <!-- START SNIPPET: javadoc -->
- * <p>
- * A tag that creates an HTML <a/> element, that when clicked makes an asynchronous request(XMLHttpRequest). The url
- * attribute must be build using the <s:url/> tag.
- * </p>
- * <!-- END SNIPPET: javadoc -->
- * <p>Examples</p>
- *
- * <!-- START SNIPPET: example1 -->
- * <div id="div1">Div 1</div>
- * <s:url id="ajaxTest" value="/AjaxTest.action"/>
- *
- * <sx:a id="link1" href="%{ajaxTest}" target="div1">
- * Update Content
- * </sx:a>
- * <!-- END SNIPPET: example1 -->
- *
- * <!-- START SNIPPET: example2 -->
- * <s:form id="form" action="AjaxTest">
- * <input type="textbox" name="data">
- * <sx:a>Submit form</sx:a>
- * </s:form>
- * <!-- END SNIPPET: example2 -->
- *
- * <!-- START SNIPPET: example3 -->
- * <s:form id="form" action="AjaxTest">
- * <input type="textbox" name="data">
- * </s:form>
- *
- * <sx:a formId="form">Submit form</sx:a>
- * <!-- END SNIPPET: example3 -->
- *
- * <!-- START SNIPPET: example4 -->
- * <script type="text/javascript">
- * dojo.event.topic.subscribe("/before", function(event, widget){
- * alert('inside a topic event. before request');
- * //event: set event.cancel = true, to cancel request
- * //widget: widget that published the topic
- * });
- * </script>
- *
- * <sx:a beforeNotifyTopics="/before">Publish topics</sx:a>
- * <!-- END SNIPPET: example4 -->
- *
- * <!-- START SNIPPET: example5 -->
- * <script type="text/javascript">
- * dojo.event.topic.subscribe("/after", function(data, request, widget){
- * alert('inside a topic event. after request');
- * //data : text returned from request(the html)
- * //request: XMLHttpRequest object
- * //widget: widget that published the topic
- * });
- * </script>
- *
- * <sx:a afterNotifyTopics="/after" highlightColor="red" href="%{#ajaxTest}">Publish topics</sx:a>
- * <!-- END SNIPPET: example5 -->
- *
- * <!-- START SNIPPET: example6 -->
- * <script type="text/javascript">
- * dojo.event.topic.subscribe("/error", function(error, request, widget){
- * alert('inside a topic event. on error');
- * //error : error object (error.message has the error message)
- * //request: XMLHttpRequest object
- * //widget: widget that published the topic
- * });
- * </script>
- *
- * <img id="ind1" src="${pageContext.request.contextPath}/images/indicator.gif" style="display:none"/>
- * <sx:a errorNotifyTopics="/error" indicator="ind1" href="%{#ajaxTest}">Publish topics</sx:a>
- * <!-- END SNIPPET: example6 -->
- */
-@StrutsTag(name="a", tldTagClass="org.apache.struts2.dojo.views.jsp.ui.AnchorTag", description="Renders an HTML anchor element that when clicked calls a URL via remote XMLHttpRequest and updates " +
- "its targets content")
-public class Anchor extends AbstractValidateBean {
- 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));
- }
-
- @Override
- @StrutsTagSkipInheritance
- public void setTheme(String theme) {
- super.setTheme(theme);
- }
-
- @StrutsTagAttribute(description="Comma delimited list of ids of the elements whose content will be updated")
- public void setTargets(String targets) {
- this.targets = targets;
- }
-}
http://git-wip-us.apache.org/repos/asf/struts/blob/17d73d21/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Autocompleter.java
----------------------------------------------------------------------
diff --git a/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Autocompleter.java b/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Autocompleter.java
deleted file mode 100644
index ad6c1f4..0000000
--- a/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Autocompleter.java
+++ /dev/null
@@ -1,528 +0,0 @@
-/*
- * $Id$
- *
- * 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.dojo.components;
-
-import java.util.Random;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.struts2.components.ComboBox;
-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;
-
-/**
- * <!-- START SNIPPET: javadoc -->
- * <p>The autocomplete tag is a combobox that can autocomplete text entered on the input box. If an action
- * is used to populate the autocompleter, the output of the action must be a well formed JSON string. </p>
- * <p>The autocompleter follows this rule to find its datasource:<p>
- * <p>1. If the response is an array, assume that it contains 2-dimension array elements, like:
- * <pre>
- * [
- * ["Alabama", "AL"],
- * ["Alaska", "AK"]
- * ]
- * </pre>
- * <p>2. If a value is specified in the "dataFieldName" attribute, and the response has a field with that
- * name, assume that's the datasource, which can be an array of 2-dimension array elements, or a map,
- * like (assuming dataFieldName="state"):</p>
- * <pre>
- * {
- * "state" : [
- * ["Alabama","AL"],
- * ["Alaska","AK"]
- * ]
- * }
- * or
- * {
- * "state" : {
- * "Alabama" : "AL",
- * "Alaska" : "AK"
- * }
- * }
- * </pre>
- * </pre>
- * <p>3. If there is a field that starts with the value specified on the "name" attribute, assume
- * that's the datasource, like (assuming name="state"):</p>
- * <pre>
- * {
- * "states" : [
- * ["Alabama","AL"],
- * ["Alaska","AK"]
- * ]
- * }
- * </pre>
- * <p>4. Use first array that is found, like:<p>
- * <pre>
- * {
- * "anything" : [
- * ["Alabama", "AL"],
- * ["Alaska", "AK"]
- * ]
- * }
- * <p>5. If the response is a map, use it (recommended as it is the easiest one to generate):
- * <pre>
- * {
- * "Alabama" : "AL",
- * "Alaska" : "AK"
- * }
- * </pre>
- * <!-- END SNIPPET: javadoc -->
- * <p>Examples</p>
- * <!-- START SNIPPET: example1 -->
- * <sx:autocompleter name="autocompleter1" href="%{jsonList}"/>
- * <!-- END SNIPPET: example1 -->
- *
- * <!-- START SNIPPET: example2 -->
- * <s:autocompleter name="test" list="{'apple','banana','grape','pear'}" autoComplete="false"/>
- * <!-- END SNIPPET: example2 -->
- *
- * <!-- START SNIPPET: example3 -->
- * <sx:autocompleter name="mvc" href="%{jsonList}" loadOnTextChange="true" loadMinimumCount="3"/>
- *
- * The text entered on the autocompleter is passed as a parameter to the url specified in "href", like (text is "struts"):
- *
- * http://host/example/myaction.do?mvc=struts
- * <!-- END SNIPPET: example3 -->
- *
- * <!-- START SNIPPET: example4 -->
- * <form id="selectForm">
- * <sx:autocompleter name="select" list="{'fruits','colors'}" valueNotifyTopics="/changed" />
- * </form>
- * <sx:autocompleter href="%{jsonList}" formId="selectForm" listenTopics="/changed"/>
- * <!-- END SNIPPET: example4 -->
- *
- * <!-- START SNIPPET: example5 -->
- * <sx:autocompleter href="%{jsonList}" id="auto"/>
- * <script type="text/javascript">
- * function getValues() {
- * var autoCompleter = dojo.widget.byId("auto");
- *
- * //key (in the states example above, "AL")
- * var key = autoCompleter.getSelectedKey();
- * alert(key);
- *
- * //value (in the states example above, "Alabama")
- * var value = autoCompleter.getSelectedValue();
- * alert(value);
- *
- * //text currently on the textbox (anything the user typed)
- * var text = autoCompleter.getText();
- * alert(text);
- * }
- *
- * function setValues() {
- * var autoCompleter = dojo.widget.byId("auto");
- *
- * //key (key will be set to "AL" and value to "Alabama")
- * autoCompleter.setSelectedKey("AL");
- *
- * //value (key will be set to "AL" and value to "Alabama")
- * autoCompleter.setAllValues("AL", "Alabama");
- * }
- * </script>
- * <!-- END SNIPPET: example5 -->
- *
- * <!-- START SNIPPET: example6 -->
- * <script type="text/javascript">
- * dojo.event.topic.subscribe("/before", function(event, widget){
- * alert('inside a topic event. before request');
- * //event: set event.cancel = true, to cancel request
- * //widget: widget that published the topic
- * });
- * </script>
- *
- * <sx:autocompleter beforeNotifyTopics="/before" href="%{#ajaxTest} />
- * <!-- END SNIPPET: example6 -->
- *
- * <!-- START SNIPPET: example7 -->
- * <script type="text/javascript">
- * dojo.event.topic.subscribe("/after", function(data, request, widget){
- * alert('inside a topic event. after request');
- * //data : JavaScript object from parsing response
- * //request: XMLHttpRequest object
- * //widget: widget that published the topic
- * });
- * </script>
- *
- * <sx:autocompleter afterNotifyTopics="/after" href="%{#ajaxTest}" />
- * <!-- END SNIPPET: example7 -->
- *
- * <!-- START SNIPPET: example8-->
- * <script type="text/javascript">
- * dojo.event.topic.subscribe("/error", function(error, request, widget){
- * alert('inside a topic event. on error');
- * //error : error object (error.message has the error message)
- * //request: XMLHttpRequest object
- * //widget: widget that published the topic
- * });
- * </script>
- *
- * <sx:autocompleter errorNotifyTopics="/error" href="%{#ajaxTest}" />
- * <!-- END SNIPPET: example8 -->
- *
- * <!-- START SNIPPET: example9 -->
- * <script type="text/javascript">
- * dojo.event.topic.subscribe("/value", function(value, key, text, widget){
- * alert('inside a topic event. after value changed');
- * //value : selected value (like "Florida" in example above)
- * //key: selected key (like "FL" in example above)
- * //text: text typed into textbox
- * //widget: widget that published the topic
- * });
- * </script>
- *
- * <sx:autocompleter valueNotifyTopics="/value" href="%{#ajaxTest}" />
- * <!-- END SNIPPET: example9 -->
- */
-@StrutsTag(name="autocompleter", tldTagClass="org.apache.struts2.dojo.views.jsp.ui.AutocompleterTag", description="Renders a combobox with autocomplete and AJAX capabilities")
-public class Autocompleter extends ComboBox {
- public static final String TEMPLATE = "autocompleter";
- final private static String COMPONENT_NAME = Autocompleter.class.getName();
- private final static transient Random RANDOM = new Random();
-
- protected String forceValidOption;
- protected String searchType;
- protected String autoComplete;
- protected String delay;
- protected String disabled;
- protected String href;
- protected String dropdownWidth;
- protected String dropdownHeight;
- protected String formId;
- protected String formFilter;
- protected String listenTopics;
- protected String notifyTopics;
- protected String indicator;
- protected String loadOnTextChange;
- protected String loadMinimumCount;
- protected String showDownArrow;
- protected String templateCssPath;
- protected String iconPath;
- protected String keyName;
- protected String dataFieldName;
- protected String beforeNotifyTopics;
- protected String afterNotifyTopics;
- protected String errorNotifyTopics;
- protected String valueNotifyTopics;
- protected String resultsLimit;
- protected String transport;
- protected String preload;
- protected String keyValue;
-
- public Autocompleter(ValueStack stack, HttpServletRequest request,
- HttpServletResponse response) {
- super(stack, request, response);
- }
-
- protected String getDefaultTemplate() {
- return TEMPLATE;
- }
-
- public String getComponentName() {
- return COMPONENT_NAME;
- }
-
-
- public void evaluateExtraParams() {
- super.evaluateExtraParams();
-
- if (forceValidOption != null)
- addParameter("forceValidOption", findValue(forceValidOption,
- Boolean.class));
- if (searchType != null) {
- String type = findString(searchType);
- if(type != null)
- addParameter("searchType", type.toUpperCase());
- }
- if (autoComplete != null)
- addParameter("autoComplete", findValue(autoComplete, Boolean.class));
- if (delay != null)
- addParameter("delay", findValue(delay, Integer.class));
- if (disabled != null)
- addParameter("disabled", findValue(disabled, Boolean.class));
- if (href != null) {
- addParameter("href", findString(href));
- addParameter("mode", "remote");
- }
- if (dropdownHeight != null)
- addParameter("dropdownHeight", findValue(dropdownHeight, Integer.class));
- if (dropdownWidth != null)
- addParameter("dropdownWidth", findValue(dropdownWidth, Integer.class));
- if (formFilter != null)
- addParameter("formFilter", findString(formFilter));
- if (formId != null)
- addParameter("formId", findString(formId));
- if (listenTopics != null)
- addParameter("listenTopics", findString(listenTopics));
- if (notifyTopics != null)
- addParameter("notifyTopics", findString(notifyTopics));
- if (indicator != null)
- addParameter("indicator", findString(indicator));
- if (loadOnTextChange != null)
- addParameter("loadOnTextChange", findValue(loadOnTextChange, Boolean.class));
- if (loadMinimumCount != null)
- addParameter("loadMinimumCount", findValue(loadMinimumCount, Integer.class));
- if (showDownArrow != null)
- addParameter("showDownArrow", findValue(showDownArrow, Boolean.class));
- else
- addParameter("showDownArrow", Boolean.TRUE);
- if (templateCssPath != null)
- addParameter("templateCssPath", findString(templateCssPath));
- if (iconPath != null)
- addParameter("iconPath", findString(iconPath));
- if (dataFieldName != null)
- addParameter("dataFieldName", findString(dataFieldName));
- if (keyName != null)
- addParameter("keyName", findString(keyName));
- else {
- keyName = name + "Key";
- addParameter("keyName", findString(keyName));
- }
- if (transport != null)
- addParameter("transport", findString(transport));
- if (preload != null)
- addParameter("preload", findValue(preload, Boolean.class));
-
- if (keyValue != null)
- addParameter("nameKeyValue", findString(keyValue));
- else {
- String keyNameExpr = "%{" + keyName + "}";
- addParameter("nameKeyValue", findString(keyNameExpr));
- }
-
-
- if (beforeNotifyTopics != null)
- addParameter("beforeNotifyTopics", findString(beforeNotifyTopics));
- if (afterNotifyTopics != null)
- addParameter("afterNotifyTopics", findString(afterNotifyTopics));
- if (errorNotifyTopics != null)
- addParameter("errorNotifyTopics", findString(errorNotifyTopics));
- if (valueNotifyTopics != null)
- addParameter("valueNotifyTopics", findString(valueNotifyTopics));
- if (resultsLimit != null)
- addParameter("searchLimit", findString(resultsLimit));
-
- // generate a random ID if not explicitly set and not parsing the content
- Boolean parseContent = (Boolean)stack.getContext().get(Head.PARSE_CONTENT);
- boolean generateId = (parseContent != null ? !parseContent : true);
-
- addParameter("pushId", generateId);
- if ((this.id == null || this.id.length() == 0) && generateId) {
- // resolves Math.abs(Integer.MIN_VALUE) issue reported by FindBugs
- // http://findbugs.sourceforge.net/bugDescriptions.html#RV_ABSOLUTE_VALUE_OF_RANDOM_INT
- int nextInt = RANDOM.nextInt();
- nextInt = nextInt == Integer.MIN_VALUE ? Integer.MAX_VALUE : Math.abs(nextInt);
- this.id = "widget_" + String.valueOf(nextInt);
- }
- }
-
- @Override
- @StrutsTagSkipInheritance
- public void setTheme(String theme) {
- super.setTheme(theme);
- }
-
- @Override
- public String getTheme() {
- return "ajax";
- }
-
- protected Object findListValue() {
- return (list != null) ? findValue(list, Object.class) : null;
- }
-
- @StrutsTagAttribute(description="Whether autocompleter should make suggestion on the textbox", type="Boolean", defaultValue="false")
- public void setAutoComplete(String autoComplete) {
- this.autoComplete = autoComplete;
- }
-
- @StrutsTagAttribute(description="Enable or disable autocompleter", type="Boolean", defaultValue="false")
- public void setDisabled(String disabled) {
- this.disabled = disabled;
- }
-
- @StrutsTagAttribute(description="Force selection to be one of the options", type="Boolean", defaultValue="false")
- public void setForceValidOption(String forceValidOption) {
- this.forceValidOption = forceValidOption;
- }
-
- @StrutsTagAttribute(description="The URL used to load the options")
- public void setHref(String href) {
- this.href = href;
- }
-
- @StrutsTagAttribute(description="Delay before making the search", type="Integer", defaultValue="100")
- public void setDelay(String searchDelay) {
- this.delay = searchDelay;
- }
-
- @StrutsTagAttribute(description="how the search must be performed, options are: 'startstring', 'startword' " +
- "and 'substring'", defaultValue="stringstart")
- public void setSearchType(String searchType) {
- this.searchType = searchType;
- }
-
- @StrutsTagAttribute(description="Dropdown's height in pixels", type="Integer", defaultValue="120")
- public void setDropdownHeight(String height) {
- this.dropdownHeight = height;
- }
-
- @StrutsTagAttribute(description="Dropdown's width", type="Integer", defaultValue="same as textbox")
- public void setDropdownWidth(String width) {
- this.dropdownWidth = width;
- }
-
- @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="Topic that will trigger a reload")
- public void setListenTopics(String listenTopics) {
- this.listenTopics = listenTopics;
- }
-
- @StrutsTagAttribute(description="Topics that will be published when content is reloaded")
- public void setNotifyTopics(String onValueChangedPublishTopic) {
- this.notifyTopics = onValueChangedPublishTopic;
- }
-
- @StrutsTagAttribute(description="Id of element that will be shown while request is made")
- public void setIndicator(String indicator) {
- this.indicator = indicator;
- }
-
- @StrutsTagAttribute(description="Minimum number of characters that will force the content to be loaded", type="Integer", defaultValue="3")
- public void setLoadMinimumCount(String loadMinimumCount) {
- this.loadMinimumCount = loadMinimumCount;
- }
-
- @StrutsTagAttribute(description="Options will be reloaded everytime a character is typed on the textbox", type="Boolean", defaultValue="true")
- public void setLoadOnTextChange(String loadOnType) {
- this.loadOnTextChange = loadOnType;
- }
-
- @StrutsTagAttribute(description="Show or hide the down arrow button", type="Boolean", defaultValue="true")
- public void setShowDownArrow(String showDownArrow) {
- this.showDownArrow = showDownArrow;
- }
-
- // Override as not required
- @StrutsTagAttribute(description="Iteratable source to populate from.")
- public void setList(String list) {
- super.setList(list);
- }
-
- @StrutsTagAttribute(description="Template css path")
- public void setTemplateCssPath(String templateCssPath) {
- this.templateCssPath = templateCssPath;
- }
-
- @StrutsTagAttribute(description="Path to icon used for the dropdown")
- public void setIconPath(String iconPath) {
- this.iconPath = iconPath;
- }
-
- @StrutsTagAttribute(description="Name of the field to which the selected key will be assigned")
- public void setKeyName(String keyName) {
- this.keyName = keyName;
- }
-
- @StrutsTagAttribute(description="Name of the field in the returned JSON object that contains the data array", defaultValue="Value specified in 'name'")
- 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);
- }
-
- @StrutsTagAttribute(description="Comma delimmited list of topics that will published after the request(if the request succeeds)")
- public void setAfterNotifyTopics(String afterNotifyTopics) {
- this.afterNotifyTopics = afterNotifyTopics;
- }
-
- @StrutsTagAttribute(description="Comma delimmited list of topics that will published before the request")
- public void setBeforeNotifyTopics(String beforeNotifyTopics) {
- this.beforeNotifyTopics = beforeNotifyTopics;
- }
-
- @StrutsTagAttribute(description="Comma delimmited list of topics that will published after the request(if the request fails)")
- public void setErrorNotifyTopics(String errorNotifyTopics) {
- this.errorNotifyTopics = errorNotifyTopics;
- }
-
- @StrutsTagAttribute(description="Comma delimmited list of topics that will published when a value is selected")
- public void setValueNotifyTopics(String valueNotifyTopics) {
- this.valueNotifyTopics = valueNotifyTopics;
- }
-
- @StrutsTagAttribute(description="Limit how many results are shown as autocompletion options, set to -1 for unlimited results", defaultValue="30", type = "Integer")
- public void setResultsLimit(String resultsLimit) {
- this.resultsLimit = resultsLimit;
- }
-
- @StrutsTagAttribute(description="Transport used by Dojo to make the request", defaultValue="XMLHTTPTransport")
- public void setTransport(String transport) {
- this.transport = transport;
- }
-
- @StrutsTagAttribute(description="Load options when page is loaded", type="Boolean", defaultValue="true")
- public void setPreload(String preload) {
- this.preload = preload;
- }
-
- @StrutsTagAttribute(description="Initial key value")
- public void setKeyValue(String keyValue) {
- this.keyValue = keyValue;
- }
-}
http://git-wip-us.apache.org/repos/asf/struts/blob/17d73d21/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Bind.java
----------------------------------------------------------------------
diff --git a/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Bind.java b/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Bind.java
deleted file mode 100644
index 76a9638..0000000
--- a/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Bind.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/*
- * $Id$
- *
- * 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.dojo.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;
-
-/**
- * <!-- START SNIPPET: javadoc -->
- * <p>
- * This tag will generate event listeners for multiple events on multiple sources,
- * making an asynchronous request to the specified href, and updating multiple targets.
- * </p>
- * <!-- END SNIPPET: javadoc -->
- *
- * <p>Examples</p>
- *
- * <!-- START SNIPPET: example0 -->
- * <sx:bind href="%{#ajaxTest}" listenTopics="/makecall"/>
- * <s:submit onclick="dojo.event.topic.publish('/makecall')"/>
- * <!-- END SNIPPET: example0 -->
- *
- * <!-- START SNIPPET: example1 -->
- * <img id="indicator" src="${pageContext.request.contextPath}/images/indicator.gif" alt="Loading..." style="display:none"/>
- * <sx:bind id="ex1" href="%{#ajaxTest}" sources="button" targets="div1" events="onclick" indicator="indicator" />
- * <s:submit theme="simple" type="submit" value="submit" id="button"/>
- * <!-- END SNIPPET: example1 -->
- *
- * <!-- START SNIPPET: example2 -->
- * <sx:bind id="ex3" href="%{#ajaxTest}" sources="chk1" targets="div1" events="onchange" formId="form1" />
- * <form id="form1">
- * <s:checkbox name="data" label="Hit me" id="chk1"/>
- * </form>
- * <!-- END SNIPPET: example2 -->
- *
- * <!-- START SNIPPET: example4 -->
- * <script type="text/javascript">
- * dojo.event.topic.subscribe("/before", function(event, widget){
- * alert('inside a topic event. before request');
- * //event: set event.cancel = true, to cancel request
- * //widget: widget that published the topic
- * });
- * </script>
- *
- * <input type="button" id="button">
- * <sx:bind id="ex1" href="%{#ajaxTest}" beforeNotifyTopics="/before" sources="button" events="onclick"/>
- * <!-- END SNIPPET: example4 -->
- *
- * <!-- START SNIPPET: example5 -->
- * <script type="text/javascript">
- * dojo.event.topic.subscribe("/after", function(data, request, widget){
- * alert('inside a topic event. after request');
- * //data : text returned from request(the html)
- * //request: XMLHttpRequest object
- * //widget: widget that published the topic
- * });
- * </script>
- *
- * <input type="button" id="button">
- * <sx:bind id="ex1" href="%{#ajaxTest}" highlightColor="red" afterNotifyTopics="/after" sources="button" events="onclick"/>
- * <!-- END SNIPPET: example5 -->
- *
- * <!-- START SNIPPET: example6 -->
- * <script type="text/javascript">
- * dojo.event.topic.subscribe("/error", function(error, request, widget){
- * alert('inside a topic event. on error');
- * //error : error object (error.message has the error message)
- * //request: XMLHttpRequest object
- * //widget: widget that published the topic
- * });
- * </script>
- *
- * <input type="button" id="button">
- * <img id="ind1" src="${pageContext.request.contextPath}/images/indicator.gif" style="display:none"/>
- * <sx:bind href="%{#ajaxTest}" indicator="ind1" errorNotifyTopics="/error" sources="button" events="onclick"/>
- * <!-- END SNIPPET: example6 -->
- */
-@StrutsTag(name="bind", tldTagClass="org.apache.struts2.dojo.views.jsp.ui.BindTag", description="Attach event listeners to elements to make AJAX calls")
-@StrutsTagSkipInheritance
-public class Bind extends AbstractValidateBean {
- public static final String TEMPLATE = "bind-close";
- public static final String OPEN_TEMPLATE = "bind";
-
- protected String targets;
- protected String sources;
- protected String events;
-
- public Bind(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));
- if (sources != null)
- addParameter("sources", findString(sources));
- if (events != null)
- addParameter("events", findString(events));
- }
-
- @StrutsTagAttribute(description="Comma delimited list of event names to attach to")
- public void setEvents(String events) {
- this.events = events;
- }
-
- @StrutsTagAttribute(description="Comma delimited list of ids of the elements to attach to")
- public void setSources(String sources) {
- this.sources = sources;
- }
-
- @StrutsTagAttribute(description="Comma delimited list of ids of the elements whose content will be updated")
- public void setTargets(String targets) {
- this.targets = targets;
- }
-
- @Override
- @StrutsTagSkipInheritance
- public void setTheme(String theme) {
- super.setTheme(theme);
- }
-
- @Override
- public String getTheme() {
- return "ajax";
- }
-
- //these attributes are overwritten here just for the TLD generation
-
- @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;
- }
-
- @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="Comma delimmited list of topics that will published before and after the request, and on errors")
- 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="false")
- public void setShowLoadingText(String showLoadingText) {
- this.showLoadingText = showLoadingText;
- }
-
- @StrutsTagSkipInheritance
- public void setCssClass(String cssClass) {
- super.setCssClass(cssClass);
- }
-
- @StrutsTagSkipInheritance
- public void setCssStyle(String cssStyle) {
- super.setCssStyle(cssStyle);
- }
-
- @StrutsTagSkipInheritance
- public void setName(String name) {
- super.setName(name);
- }
-
- @StrutsTagAttribute(description="Comma delimmited list of topics that will published after the request(if the request succeeds)")
- public void setAfterNotifyTopics(String afterNotifyTopics) {
- this.afterNotifyTopics = afterNotifyTopics;
- }
-
- @StrutsTagAttribute(description="Comma delimmited list of topics that will published before the request")
- public void setBeforeNotifyTopics(String beforeNotifyTopics) {
- this.beforeNotifyTopics = beforeNotifyTopics;
- }
-
- @StrutsTagAttribute(description="Comma delimmited list of topics that will published after the request(if the request fails)")
- public void setErrorNotifyTopics(String errorNotifyTopics) {
- this.errorNotifyTopics = errorNotifyTopics;
- }
-
- @StrutsTagAttribute(description="The id to use for the element")
- public void setId(String id) {
- super.setId(id);
- }
-
- @StrutsTagAttribute(description = "Color used to perform a highlight effect on the elements specified in the 'targets' attribute",
- defaultValue = "none")
- public void setHighlightColor(String highlightColor) {
- this.highlightColor = highlightColor;
- }
-
- @StrutsTagAttribute(description = "Duration of highlight effect in milliseconds. Only valid if 'highlightColor' attribute is set",
- defaultValue = "2000", type="Integer")
- public void setHighlightDuration(String highlightDuration) {
- this.highlightDuration = highlightDuration;
- }
-
- @StrutsTagAttribute(description = "Perform Ajax validation. 'ajaxValidation' interceptor must be applied to action", type="Boolean",
- defaultValue = "false")
- public void setValidate(String validate) {
- this.validate = validate;
- }
-
- @StrutsTagAttribute(description = "Make an asynchronous request if validation succeeds. Only valid is 'validate' is 'true'", type="Boolean",
- defaultValue = "false")
- public void setAjaxAfterValidation(String ajaxAfterValidation) {
- this.ajaxAfterValidation = ajaxAfterValidation;
- }
-
- @StrutsTagAttribute(description="Run scripts in a separate scope, unique for each tag", defaultValue="true")
- public void setSeparateScripts(String separateScripts) {
- this.separateScripts = separateScripts;
- }
-
- @StrutsTagAttribute(description="Transport used by Dojo to make the request", defaultValue="XMLHTTPTransport")
- public void setTransport(String transport) {
- this.transport = transport;
- }
-}
http://git-wip-us.apache.org/repos/asf/struts/blob/17d73d21/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/DateTimePicker.java
----------------------------------------------------------------------
diff --git a/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/DateTimePicker.java b/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/DateTimePicker.java
deleted file mode 100644
index 8659560..0000000
--- a/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/DateTimePicker.java
+++ /dev/null
@@ -1,435 +0,0 @@
-/*
- * $Id$
- *
- * 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.dojo.components;
-
-import java.text.DateFormat;
-import java.text.Format;
-import java.text.MessageFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
-import java.util.Random;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.struts2.components.UIBean;
-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;
-import com.opensymphony.xwork2.util.logging.Logger;
-import com.opensymphony.xwork2.util.logging.LoggerFactory;
-
-/**
- * <!-- START SNIPPET: javadoc -->
- * <p>
- * Renders a date/time picker in a dropdown container.
- * </p>
- * <p>
- * A stand-alone DateTimePicker widget that makes it easy to select a date/time, or increment by week, month,
- * and/or year.
- * </p>
- *
- * <p>
- * It is possible to customize the user-visible formatting with either the
- * 'formatLength' (long, short, medium or full) or 'displayFormat' attributes. By defaulty current
- * locale will be used.</p>
- * </p>
- *
- * Syntax supported by 'displayFormat' is (http://www.unicode.org/reports/tr35/tr35-4.html#Date_Format_Patterns):-
- * <table border="1">
- * <tr>
- * <td>Format</td>
- * <td>Description</td>
- * </tr>
- * <tr>
- * <td>d</td>
- * <td>Day of the month</td>
- * </tr>
- * <tr>
- * <td>D</td>
- * <td>Day of year</td>
- * </tr>
- * <tr>
- * <td>M</td>
- * <td>Month - Use one or two for the numerical month, three for the abbreviation, or four for the full name, or 5 for the narrow name.</td>
- * </tr>
- * <tr>
- * <td>y</td>
- * <td>Year</td>
- * </tr>
- * <tr>
- * <td>h</td>
- * <td>Hour [1-12].</td>
- * </tr>
- * <tr>
- * <td>H</td>
- * <td>Hour [0-23].</td>
- * </tr>
- * <tr>
- * <td>m</td>
- * <td>Minute. Use one or two for zero padding.</td>
- * </tr>
- * <tr>
- * <td>s</td>
- * <td>Second. Use one or two for zero padding.</td>
- * </tr>
- * </table>
- *
- * <p>
- * The value sent to the server is a locale-independent value, in a hidden field as defined
- * by the name attribute. The value will be formatted conforming to RFC3 339
- * (yyyy-MM-dd'T'HH:mm:ss)
- * </p>
- * <p>
- * The following formats(in order) will be used to parse the values of the attributes 'value',
- * 'startDate' and 'endDate':
- * </p>
- * <ul>
- * <li>SimpleDateFormat built using RFC 3339 (yyyy-MM-dd'T'HH:mm:ss)
- * <li>SimpleDateFormat.getTimeInstance(DateFormat.SHORT)
- * <li>SimpleDateFormat.getDateInstance(DateFormat.SHORT)
- * <li>SimpleDateFormat.getDateInstance(DateFormat.MEDIUM)
- * <li>SimpleDateFormat.getDateInstance(DateFormat.FULL)
- * <li>SimpleDateFormat.getDateInstance(DateFormat.LONG)
- * <li>SimpleDateFormat built using the value of the 'displayFormat' attribute(if any)
- * </ul>
- * <!-- END SNIPPET: javadoc -->
- *
- * <b>Examples</b>
- *
- * <pre>
- * <!-- START SNIPPET: example1 -->
- * <sx:datetimepicker name="order.date" label="Order Date" />
- * <sx:datetimepicker name="delivery.date" label="Delivery Date" displayFormat="yyyy-MM-dd" />
- * <sx:datetimepicker name="delivery.date" label="Delivery Date" value="%{date}" />
- * <sx:datetimepicker name="delivery.date" label="Delivery Date" value="%{'2007-01-01'}" />
- * <sx:datetimepicker name="order.date" label="Order Date" value="%{'today'}"/>
- * <!-- END SNIPPET: example1 -->
- * </pre>
- *
- * <!-- START SNIPPET: example2 -->
- * <sx:datetimepicker id="picker" label="Order Date" />
- * <script type="text/javascript">
- * function setValue() {
- * var picker = dojo.widget.byId("picker");
- *
- * //string value
- * picker.setValue('2007-01-01');
- *
- * //Date value
- * picker.setValue(new Date());
- * }
- *
- * function showValue() {
- * var picker = dojo.widget.byId("picker");
- *
- * //string value
- * var stringValue = picker.getValue();
- * alert(stringValue);
- *
- * //date value
- * var dateValue = picker.getDate();
- * alert(dateValue);
- * }
- * </script>
- * <!-- END SNIPPET: example2 -->
- *
- * <!-- START SNIPPET: example3 -->
- * <sx:datetimepicker id="picker" label="Order Date" valueNotifyTopics="/value"/>
- *
- * <script type="text/javascript">
- * dojo.event.topic.subscribe("/value", function(textEntered, date, widget){
- * alert('value changed');
- * //textEntered: String enetered in the textbox
- * //date: JavaScript Date object with the value selected
- * //widet: widget that published the topic
- * });
- * </script>
- * <!-- END SNIPPET: example3 -->
- */
-@StrutsTag(name="datetimepicker", tldTagClass="org.apache.struts2.dojo.views.jsp.ui.DateTimePickerTag", description="Render datetimepicker")
-public class DateTimePicker extends UIBean {
-
- final public static String TEMPLATE = "datetimepicker";
- // SimpleDateFormat is not thread-safe see:
- // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6231579
- // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6178997
- // solution is to use stateless MessageFormat instead:
- final private static String RFC3339_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";
- final private static String RFC3339_PATTERN = "{0,date," + RFC3339_FORMAT + "}";
- final protected static Logger LOG = LoggerFactory.getLogger(DateTimePicker.class);
- final private static transient Random RANDOM = new Random();
-
- protected String iconPath;
- protected String formatLength;
- protected String displayFormat;
- protected String toggleType;
- protected String toggleDuration;
- protected String type;
-
- protected String displayWeeks;
- protected String adjustWeeks;
- protected String startDate;
- protected String endDate;
- protected String weekStartsOn;
- protected String staticDisplay;
- protected String dayWidth;
- protected String language;
- protected String templateCssPath;
- protected String valueNotifyTopics;
-
- public DateTimePicker(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
- super(stack, request, response);
- }
-
- protected String getDefaultTemplate() {
- return TEMPLATE;
- }
-
- public void evaluateParams() {
- super.evaluateParams();
-
- if(displayFormat != null)
- addParameter("displayFormat", findString(displayFormat));
- if(displayWeeks != null)
- addParameter("displayWeeks", findString(displayWeeks));
- if(adjustWeeks != null)
- addParameter("adjustWeeks", findValue(adjustWeeks, Boolean.class));
-
- if(disabled != null)
- addParameter("disabled", findValue(disabled, Boolean.class));
-
- if(startDate != null)
- addParameter("startDate", format(findValue(startDate)));
- if(endDate != null)
- addParameter("endDate", format(findValue(endDate)));
- if(weekStartsOn != null)
- addParameter("weekStartsOn", findString(weekStartsOn));
- if(staticDisplay != null)
- addParameter("staticDisplay", findValue(staticDisplay, Boolean.class));
- if(dayWidth != null)
- addParameter("dayWidth", findValue(dayWidth, Integer.class));
- if(language != null)
- addParameter("language", findString(language));
- if(value != null)
- addParameter("value", format(findValue(value)));
-
- if(iconPath != null)
- addParameter("iconPath", findString(iconPath));
- if(formatLength != null)
- addParameter("formatLength", findString(formatLength));
- if(toggleType != null)
- addParameter("toggleType", findString(toggleType));
- if(toggleDuration != null)
- addParameter("toggleDuration", findValue(toggleDuration,
- Integer.class));
- if(type != null)
- addParameter("type", findString(type));
- else
- addParameter("type", "date");
- if(templateCssPath != null)
- addParameter("templateCssPath", findString(templateCssPath));
- if(valueNotifyTopics != null)
- addParameter("valueNotifyTopics", findString(valueNotifyTopics));
-
- // format the value to RFC 3399
- if(parameters.containsKey("value")) {
- addParameter("nameValue", parameters.get("value"));
- } else {
- if(parameters.containsKey("name")) {
- addParameter("nameValue", format(findValue((String)parameters.get("name"))));
- }
- }
-
- // generate a random ID if not explicitly set and not parsing the content
- Boolean parseContent = (Boolean)stack.getContext().get(Head.PARSE_CONTENT);
- boolean generateId = (parseContent != null ? !parseContent : true);
-
- addParameter("pushId", generateId);
- if ((this.id == null || this.id.length() == 0) && generateId) {
- // resolves Math.abs(Integer.MIN_VALUE) issue reported by FindBugs
- // http://findbugs.sourceforge.net/bugDescriptions.html#RV_ABSOLUTE_VALUE_OF_RANDOM_INT
- int nextInt = RANDOM.nextInt();
- nextInt = nextInt == Integer.MIN_VALUE ? Integer.MAX_VALUE : Math.abs(nextInt);
- this.id = "widget_" + String.valueOf(nextInt);
- addParameter("id", this.id);
- }
- }
-
- @Override
- @StrutsTagSkipInheritance
- public void setTheme(String theme) {
- super.setTheme(theme);
- }
-
- @Override
- public String getTheme() {
- return "ajax";
- }
-
- @StrutsTagAttribute(description="If true, weekly size of calendar changes to acomodate the month if false," +
- " 42 day format is used", type="Boolean", defaultValue="false")
- public void setAdjustWeeks(String adjustWeeks) {
- this.adjustWeeks = adjustWeeks;
- }
-
- @StrutsTagAttribute(description="How to render the names of the days in the header(narrow, abbr or wide)", defaultValue="narrow")
- public void setDayWidth(String dayWidth) {
- this.dayWidth = dayWidth;
- }
-
- @StrutsTagAttribute(description="Total weeks to display", type="Integer", defaultValue="6")
- public void setDisplayWeeks(String displayWeeks) {
- this.displayWeeks = displayWeeks;
- }
-
- @StrutsTagAttribute(description="Last available date in the calendar set", type="Date", defaultValue="2941-10-12")
- public void setEndDate(String endDate) {
- this.endDate = endDate;
- }
-
- @StrutsTagAttribute(description="First available date in the calendar set", type="Date", defaultValue="1492-10-12")
- public void setStartDate(String startDate) {
- this.startDate = startDate;
- }
-
- @StrutsTagAttribute(description="Disable all incremental controls, must pick a date in the current display", type="Boolean", defaultValue="false")
- public void setStaticDisplay(String staticDisplay) {
- this.staticDisplay = staticDisplay;
- }
-
- @StrutsTagAttribute(description="Adjusts the first day of the week 0==Sunday..6==Saturday", type="Integer", defaultValue="0")
- public void setWeekStartsOn(String weekStartsOn) {
- this.weekStartsOn = weekStartsOn;
- }
-
- @StrutsTagAttribute(description="Language to display this widget in", defaultValue="brower's specified preferred language")
- public void setLanguage(String language) {
- this.language = language;
- }
-
- @StrutsTagAttribute(description="A pattern used for the visual display of the formatted date, e.g. dd/MM/yyyy")
- public void setDisplayFormat(String displayFormat) {
- this.displayFormat = displayFormat;
- }
-
- @StrutsTagAttribute(description="Type of formatting used for visual display. Possible values are " +
- "long, short, medium or full", defaultValue="short")
- public void setFormatLength(String formatLength) {
- this.formatLength = formatLength;
- }
-
- @StrutsTagAttribute(description="Path to icon used for the dropdown")
- public void setIconPath(String iconPath) {
- this.iconPath = iconPath;
- }
-
- @StrutsTagAttribute(description="Duration of toggle in milliseconds", type="Integer", defaultValue="100")
- public void setToggleDuration(String toggleDuration) {
- this.toggleDuration = toggleDuration;
- }
-
- @StrutsTagAttribute(description="Defines the type of the picker on the dropdown. Possible values are 'date'" +
- " for a DateTimePicker, and 'time' for a timePicker", defaultValue="date")
- public void setType(String type) {
- this.type = type;
- }
-
- @StrutsTagAttribute(description="oggle type of the dropdown. Possible values are plain,wipe,explode,fade", defaultValue="plain")
- public void setToggleType(String toggleType) {
- this.toggleType = toggleType;
- }
-
- @StrutsTagAttribute(description="Template css path")
- public void setTemplateCssPath(String templateCssPath) {
- this.templateCssPath = templateCssPath;
- }
-
- @StrutsTagAttribute(description="Preset the value of input element")
- public void setValue(String arg0) {
- super.setValue(arg0);
- }
-
- @StrutsTagAttribute(description="Comma delimmited list of topics that will published when a value is selected")
- public void setValueNotifyTopics(String valueNotifyTopics) {
- this.valueNotifyTopics = valueNotifyTopics;
- }
-
- private String format(Object obj) {
- if(obj == null)
- return null;
-
- if(obj instanceof Date) {
- return MessageFormat.format(RFC3339_PATTERN, (Date) obj);
- } else if(obj instanceof Calendar) {
- return MessageFormat.format(RFC3339_PATTERN, ((Calendar) obj).getTime());
- }
- else {
- // try to parse a date
- String dateStr = obj.toString();
- if(dateStr.equalsIgnoreCase("today"))
- return MessageFormat.format(RFC3339_PATTERN, new Date());
-
-
- Date date = null;
- //formats used to parse the date
- List<DateFormat> formats = new ArrayList<DateFormat>();
- formats.add(new SimpleDateFormat(RFC3339_FORMAT));
- formats.add(SimpleDateFormat.getTimeInstance(DateFormat.SHORT));
- formats.add(SimpleDateFormat.getDateInstance(DateFormat.SHORT));
- formats.add(SimpleDateFormat.getDateInstance(DateFormat.MEDIUM));
- formats.add(SimpleDateFormat.getDateInstance(DateFormat.FULL));
- formats.add(SimpleDateFormat.getDateInstance(DateFormat.LONG));
- if (this.displayFormat != null) {
- try {
- SimpleDateFormat displayFormat = new SimpleDateFormat(
- (String) getParameters().get("displayFormat"));
- formats.add(displayFormat);
- } catch (Exception e) {
- // don't use it then (this attribute is used by Dojo, not java code)
- LOG.error("Cannot use attribute", e);
- }
- }
-
- for (DateFormat format : formats) {
- try {
- date = format.parse(dateStr);
- if (date != null)
- return MessageFormat.format(RFC3339_PATTERN, date);
- } catch (Exception e) {
- //keep going
- }
- }
-
- // last resource, assume already in correct/default format
- if (LOG.isDebugEnabled())
- LOG.debug("Unable to parse date " + dateStr);
- return dateStr;
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/struts/blob/17d73d21/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Div.java
----------------------------------------------------------------------
diff --git a/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Div.java b/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Div.java
deleted file mode 100644
index ae45789..0000000
--- a/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Div.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * $Id$
- *
- * 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.dojo.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;
-
-/**
- * <!-- START SNIPPET: javadoc -->
- * <p>
- * This tag generates an HTML div that loads its content using an XMLHttpRequest call, via
- * the dojo framework. When the "updateFreq" is set the built in timer will start automatically and
- * reload the div content with the value of "updateFreq" as the refresh period(in milliseconds).
- * Topics can be used to stop(stopTimerListenTopics) and start(startTimerListenTopics) this timer.
- * </p>
- * <p>
- * When used inside a "tabbedpanel" tag, each div becomes a tab. Some attributes are specific
- * to this use case, like:
- * <ul>
- * <li>refreshOnShow: div content is realoded when tab is selected</li>
- * <li>closable: Tab will have close button</li>
- * <li>preload: load div content after page is loaded</li>
- * </ul>
- * </p>
- * <!-- END SNIPPET: javadoc -->
- *
- * <p>Examples</p>
- * <!-- START SNIPPET: example1 -->
- * <sx:div href="%{#url}">Initial Content</sx:div>
- * <!-- END SNIPPET: example1 -->
- *
- * <!-- START SNIPPET: example2 -->
- * <img id="indicator" src="${pageContext.request.contextPath}/images/indicator.gif" style="display:none"/>
- * <sx:div href="%{#url}" updateFreq="2000" indicator="indicator">
- * Initial Content
- * </sx:div>
- * <!-- END SNIPPET: example2 -->
- *
- * <!-- START SNIPPET: example3 -->
- * <form id="form">
- * <label for="textInput">Text to be submited when div reloads</label>
- * <input type=textbox id="textInput" name="data">
- * </form>
- * <sx:div
- * href="%{#url}"
- * updateFreq="3000"
- * listenTopics="/refresh"
- * startTimerListenTopics="/startTimer"
- * stopTimerListenTopics="/stopTimer"
- * highlightColor="red"
- * formId="form">
- * Initial Content
- * </sx:div>
- * <!-- END SNIPPET: example3 -->
- */
-@StrutsTag(name="div", tldTagClass="org.apache.struts2.dojo.views.jsp.ui.DivTag", description="Render HTML div providing content from remote call via AJAX")
-public class Div extends AbstractRemoteBean {
-
- 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 updateFreq;
- protected String autoStart;
- protected String delay;
- protected String startTimerListenTopics;
- protected String stopTimerListenTopics;
- protected String refreshOnShow;
- protected String closable;
- protected String preload;
-
- public Div(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
- super(stack, request, response);
- }
-
- public String getDefaultOpenTemplate() {
- return TEMPLATE;
- }
-
- protected String getDefaultTemplate() {
- return TEMPLATE_CLOSE;
- }
-
- public void evaluateExtraParams() {
- super.evaluateExtraParams();
-
- 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 (startTimerListenTopics != null)
- addParameter("startTimerListenTopics", findString(startTimerListenTopics));
- if (stopTimerListenTopics != null)
- addParameter("stopTimerListenTopics", findString(stopTimerListenTopics));
- if (separateScripts != null)
- addParameter("separateScripts", findValue(separateScripts, Boolean.class));
- if (closable != null)
- addParameter("closable", findValue(closable, Boolean.class));
- if (preload != null)
- addParameter("preload", findValue(preload, Boolean.class));
- }
-
- @StrutsTagAttribute(description="Start timer automatically", type="Boolean", defaultValue="true")
- public void setAutoStart(String autoStart) {
- this.autoStart = autoStart;
- }
-
- @StrutsTagAttribute(description="How long to wait before fetching the content (in milliseconds)", type="Integer")
- public void setDelay(String delay) {
- this.delay = delay;
- }
-
- @StrutsTagAttribute(description="How often to reload the content (in milliseconds)", type="Integer")
- public void setUpdateFreq(String updateInterval) {
- this.updateFreq = updateInterval;
- }
-
- @StrutsTagAttribute(description="Topics that will start the timer (for autoupdate)")
- public void setStartTimerListenTopics(String startTimerListenTopic) {
- this.startTimerListenTopics = startTimerListenTopic;
- }
-
- @StrutsTagAttribute(description="Topics that will stop the timer (for autoupdate)")
- public void setStopTimerListenTopics(String stopTimerListenTopic) {
- this.stopTimerListenTopics = stopTimerListenTopic;
- }
-
- @StrutsTagAttribute(description="Content will be loaded when div becomes visible, used only inside the tabbedpanel tag", type="Boolean", defaultValue="false")
- public void setRefreshOnShow(String refreshOnShow) {
- this.refreshOnShow = refreshOnShow;
- }
-
- @StrutsTagAttribute(description="Show a close button when the div is inside a 'tabbedpanel'", defaultValue="false")
- public void setClosable(String closable) {
- this.closable = closable;
- }
-
- @StrutsTagAttribute(description="Load content when page is loaded", type="Boolean", defaultValue="true")
- public void setPreload(String preload) {
- this.preload = preload;
- }
-
- @StrutsTagAttribute(description = "Color used to perform a highlight effect on this element",
- defaultValue = "none")
- public void setHighlightColor(String highlightColor) {
- this.highlightColor = highlightColor;
- }
-}