You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by ap...@apache.org on 2007/10/31 21:35:03 UTC
svn commit: r590812 [33/48] - in /struts/struts2/trunk: apps/blank/
apps/blank/src/main/java/example/ apps/blank/src/main/resources/
apps/blank/src/main/resources/example/ apps/blank/src/main/webapp/
apps/mailreader/ apps/mailreader/src/main/java/ apps...
Modified: struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Bind.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Bind.java?rev=590812&r1=590811&r2=590812&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Bind.java (original)
+++ struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Bind.java Wed Oct 31 13:32:54 2007
@@ -1,294 +1,294 @@
-/*
- * $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 calidation. '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;
- }
-}
+/*
+ * $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 calidation. '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;
+ }
+}
Propchange: struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Bind.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Bind.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/DateTimePicker.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/DateTimePicker.java?rev=590812&r1=590811&r2=590812&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/DateTimePicker.java (original)
+++ struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/DateTimePicker.java Wed Oct 31 13:32:54 2007
@@ -1,417 +1,417 @@
-/*
- * $Id: DateTimePicker.java 512580 2007-02-28 02:48:06Z 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.dojo.components;
-
-import java.text.DateFormat;
-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";
- final private static SimpleDateFormat RFC3339_FORMAT = new SimpleDateFormat(
- "yyyy-MM-dd'T'HH:mm:ss");
- final protected static Logger LOG = LoggerFactory.getLogger(DateTimePicker.class);
-
- 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(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")) {
- parameters.put("nameValue", parameters.get("value"));
- } else {
- if(name != null) {
- addParameter("nameValue", format(findValue(name)));
- }
- }
-
- boolean generateId = !(Boolean)stack.getContext().get(Head.PARSE_CONTENT);
- addParameter("pushId", generateId);
- if ((this.id == null || this.id.length() == 0) && generateId) {
- Random random = new Random();
- this.id = "widget_" + Math.abs(random.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 RFC3339_FORMAT.format((Date) obj);
- } else if(obj instanceof Calendar) {
- return RFC3339_FORMAT.format(((Calendar) obj).getTime());
- }
- else {
- // try to parse a date
- String dateStr = obj.toString();
- if(dateStr.equalsIgnoreCase("today"))
- return RFC3339_FORMAT.format(new Date());
-
-
- Date date = null;
- //formats used to parse the date
- List<DateFormat> formats = new ArrayList<DateFormat>();
- formats.add(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 RFC3339_FORMAT.format(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;
- }
- }
-
-}
+/*
+ * $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.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";
+ final private static SimpleDateFormat RFC3339_FORMAT = new SimpleDateFormat(
+ "yyyy-MM-dd'T'HH:mm:ss");
+ final protected static Logger LOG = LoggerFactory.getLogger(DateTimePicker.class);
+
+ 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(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")) {
+ parameters.put("nameValue", parameters.get("value"));
+ } else {
+ if(name != null) {
+ addParameter("nameValue", format(findValue(name)));
+ }
+ }
+
+ boolean generateId = !(Boolean)stack.getContext().get(Head.PARSE_CONTENT);
+ addParameter("pushId", generateId);
+ if ((this.id == null || this.id.length() == 0) && generateId) {
+ Random random = new Random();
+ this.id = "widget_" + Math.abs(random.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 RFC3339_FORMAT.format((Date) obj);
+ } else if(obj instanceof Calendar) {
+ return RFC3339_FORMAT.format(((Calendar) obj).getTime());
+ }
+ else {
+ // try to parse a date
+ String dateStr = obj.toString();
+ if(dateStr.equalsIgnoreCase("today"))
+ return RFC3339_FORMAT.format(new Date());
+
+
+ Date date = null;
+ //formats used to parse the date
+ List<DateFormat> formats = new ArrayList<DateFormat>();
+ formats.add(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 RFC3339_FORMAT.format(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;
+ }
+ }
+
+}
Propchange: struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/DateTimePicker.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/DateTimePicker.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Div.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Div.java?rev=590812&r1=590811&r2=590812&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Div.java (original)
+++ struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Div.java Wed Oct 31 13:32:54 2007
@@ -1,5 +1,5 @@
/*
- * $Id: Div.java 511300 2007-02-24 16:41:38Z musachy $
+ * $Id$
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Propchange: struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Div.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Div.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/RemoteBean.java
URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/RemoteBean.java?rev=590812&r1=590811&r2=590812&view=diff
==============================================================================
--- struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/RemoteBean.java (original)
+++ struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/RemoteBean.java Wed Oct 31 13:32:54 2007
@@ -1,5 +1,5 @@
/*
- * $Id: RemoteUICallBean.java 508285 2007-02-16 02:42:24Z musachy $
+ * $Id$
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Propchange: struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/RemoteBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/RemoteBean.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL