Author: musachy Date: Sat Jul 19 06:14:31 2008 New Revision: 678154 URL: http://svn.apache.org/viewvc?rev=678154&view=rev Log: WW-1677 <s:submit type="button" does not render the enclosed content inside properly
Fix build problem Added: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/submit-close.ftl (with props) Modified: struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Submit.java Modified: struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Submit.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Submit.java?rev=678154&r1=678153&r2=678154&view=diff ============================================================================== --- struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Submit.java (original) +++ struts/struts2/trunk/plugins/dojo/src/main/java/org/apache/struts2/dojo/components/Submit.java Sat Jul 19 06:14:31 2008 @@ -54,7 +54,7 @@ * <!-- START SNIPPET: example1 --> * <sx:submit value="%{'Submit'}" /> * <!-- END SNIPPET: example1 --> - * + * * <!-- START SNIPPET: example2 --> * <sx:submit type="image" value="%{'Submit'}" label="Submit the form" src="submit.gif"/> * <!-- END SNIPPET: example2 --> @@ -66,25 +66,25 @@ * <!-- START SNIPPET: example4 --> * <div id="div1">Div 1</div> * <s:url id="ajaxTest" value="/AjaxTest.action"/> - * + * * <sx:submit id="link1" href="%{ajaxTest}" target="div1" /> * <!-- END SNIPPET: example4 --> - * + * * <!-- START SNIPPET: example5 --> * <s:form id="form" action="AjaxTest"> * <input type="textbox" name="data"> - * <sx:submit /> + * <sx:submit /> * </s:form> * <!-- END SNIPPET: example5 --> - * + * * <!-- START SNIPPET: example6 --> * <s:form id="form" action="AjaxTest"> - * <input type="textbox" name="data"> + * <input type="textbox" name="data"> * </s:form> - * + * * <sx:submit formId="form" /> * <!-- END SNIPPET: example6 --> - * + * * <!-- START SNIPPET: example7 --> * <script type="text/javascript"> * dojo.event.topic.subscribe("/before", function(event, widget){ @@ -92,11 +92,11 @@ * //event: set event.cancel = true, to cancel request * //widget: widget that published the topic * }); - * </script> - * + * </script> + * * <sx:submit beforeNotifyTopics="/before" /> * <!-- END SNIPPET: example7 --> - * + * * <!-- START SNIPPET: example8 --> * <script type="text/javascript"> * dojo.event.topic.subscribe("/after", function(data, request, widget){ @@ -105,11 +105,11 @@ * //request: XMLHttpRequest object * //widget: widget that published the topic * }); - * </script> - * + * </script> + * * <sx:submit afterNotifyTopics="/after" highlightColor="red" href="%{#ajaxTest}" /> * <!-- END SNIPPET: example8 --> - * + * * <!-- START SNIPPET: example9 --> * <script type="text/javascript"> * dojo.event.topic.subscribe("/error", function(error, request, widget){ @@ -118,19 +118,20 @@ * //request: XMLHttpRequest object * //widget: widget that published the topic * }); - * </script> - * + * </script> + * * <img id="ind1" src="${pageContext.request.contextPath}/images/indicator.gif" style="display:none"/> * <sx:submit errorNotifyTopics="/error" indicator="ind1" href="%{#ajaxTest}" /> * <!-- END SNIPPET: example9 --> */ @StrutsTag(name="submit", tldTagClass="org.apache.struts2.dojo.views.jsp.ui.SubmitTag", description="Render a submit button") public class Submit extends FormButton implements RemoteBean { - + private static final Logger LOG = LoggerFactory.getLogger(Submit.class); - private final static transient Random RANDOM = new Random(); - - final public static String TEMPLATE = "submit"; + private final static transient Random RANDOM = new Random(); + + final public static String OPEN_TEMPLATE = "submit"; + final public static String TEMPLATE = "submit-close"; protected String href; protected String errorText; @@ -156,7 +157,7 @@ protected String separateScripts; protected String transport; protected String parseContent; - + public Submit(ValueStack stack, HttpServletRequest request, HttpServletResponse response) { super(stack, request, response); } @@ -165,6 +166,11 @@ return TEMPLATE; } + @Override + public String getDefaultOpenTemplate() { + return OPEN_TEMPLATE; + } + public void evaluateParams() { if ((key == null) && (value == null)) { value = "Submit"; @@ -224,30 +230,30 @@ addParameter("transport", findString(transport)); if (parseContent != null) addParameter("parseContent", findValue(parseContent, Boolean.class)); - + Boolean validateValue = false; if (validate != null) { validateValue = (Boolean) findValue(validate, Boolean.class); addParameter("validate", validateValue); - } - + } + Form form = (Form) findAncestor(Form.class); - if (form != null) + if (form != null) addParameter("parentTheme", form.getTheme()); - + if (ajaxAfterValidation != null) addParameter("ajaxAfterValidation", findValue(ajaxAfterValidation, Boolean.class)); - // generate a random ID if not explicitly set and not parsing the content + // 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 + // 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); + nextInt = nextInt == Integer.MIN_VALUE ? Integer.MAX_VALUE : Math.abs(nextInt); this.id = "widget_" + String.valueOf(nextInt); addParameter("id", this.id); } @@ -258,12 +264,12 @@ public void setTheme(String theme) { super.setTheme(theme); } - + @Override public String getTheme() { return "ajax"; } - + /** * Indicate whether the concrete button supports the type "image". * @@ -272,7 +278,7 @@ protected boolean supportsImageType() { return true; } - + /** * Overrides to be able to render body in a template rather than always before the template */ @@ -280,7 +286,7 @@ evaluateParams(); try { addParameter("body", body); - + mergeTemplate(writer, buildTemplateName(template, getDefaultTemplate())); } catch (Exception e) { LOG.error("error when rendering", e); @@ -361,7 +367,7 @@ 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); @@ -397,7 +403,7 @@ public void setLabel(String label) { super.setLabel(label); } - + @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; @@ -412,26 +418,26 @@ 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", + + @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", + @StrutsTagAttribute(description = "Duration of highlight effect in milliseconds. Only valid if 'highlightColor' attribute is set", defaultValue = "1000") public void setHighlightDuration(String highlightDuration) { this.highlightDuration = highlightDuration; } - @StrutsTagAttribute(description = "Perform Ajax validation. 'ajaxValidation' interceptor must be applied to action", type="Boolean", + @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", + @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; @@ -441,17 +447,17 @@ public void setAction(String action) { super.setAction(action); } - + @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; Added: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/submit-close.ftl URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/submit-close.ftl?rev=678154&view=auto ============================================================================== --- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/submit-close.ftl (added) +++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/submit-close.ftl Sat Jul 19 06:14:31 2008 @@ -0,0 +1,22 @@ +<#-- +/* + * $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. + */ +--> \ No newline at end of file Propchange: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/submit-close.ftl ------------------------------------------------------------------------------ svn:keywords = Id