Modified: struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/struts_dojo.js.uncompressed.js URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/struts_dojo.js.uncompressed.js?view=diff&rev=533389&r1=533388&r2=533389 ============================================================================== --- struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/struts_dojo.js.uncompressed.js (original) +++ struts/struts2/trunk/plugins/dojo/src/main/resources/org/apache/struts2/static/dojo/struts_dojo.js.uncompressed.js Sat Apr 28 09:59:01 2007 @@ -22094,7 +22094,10 @@ highlightColor : "", highlightDuration : 2000, - + + validate : false, + ajaxAfterValidation : false, + postCreate : function() { var self = this; @@ -22201,38 +22204,57 @@ }); } }, - + bindHandler : function(type, data, e) { - //hide indicator - dojo.html.hide(this.indicator); - - //publish topics - this.notify(data, type, e); - - if(type == "load") { - if(this.executeScripts) { - //update targets content - var parsed = this.parse(data); - //eval scripts - if(parsed.scripts && parsed.scripts.length > 0) { - var scripts = ""; - for(var i = 0; i < parsed.scripts.length; i++){ - scripts += parsed.scripts[i]; - } - (new Function('_container_', scripts+'; return this;'))(this); - } - this.setContent(parsed.text); - } - else { - this.setContent(data); - } - this.highlight(); - } else { - if(this.showError) { - var message = dojo.string.isBlank(this.errorText) ? e.message : this.errorText; - this.setContent(message); - } - } + //hide indicator + dojo.html.hide(this.indicator); + + //publish topics + this.notify(data, type, e); + + if(type == "load") { + if(this.validate) { + StrutsUtils.clearValidationErrors(this.formNode); + //validation is active for this action + var errors = StrutsUtils.getValidationErrors(data); + if(errors && errors.fieldErrors) { + //validation failed + StrutsUtils.showValidationErrors(this.formNode, errors); + return; + } else { + //validation passed + if(!this.ajaxAfterValidation && this.formNode) { + //regular submit + this.formNode.submit(); + return; + } + } + } + + // no validation or validation passed + if(this.executeScripts) { + //update targets content + var parsed = this.parse(data); + //eval scripts + if(parsed.scripts && parsed.scripts.length > 0) { + var scripts = ""; + for(var i = 0; i < parsed.scripts.length; i++){ + scripts += parsed.scripts[i]; + } + (new Function('_container_', scripts+'; return this;'))(this); + } + this.setContent(parsed.text); + } + else { + this.setContent(data); + } + this.highlight(); + } else { + if(this.showError) { + var message = dojo.string.isBlank(this.errorText) ? e.message : this.errorText; + this.setContent(message); + } + } }, notify : function(data, type, e) { @@ -22306,8 +22328,9 @@ } //if there is a parent form, and it has a "onsubmit" - //execute it, validation is usually there - if(this.formNode && this.formNode.onsubmit != null) { + //execute it, validation is usually there, except is validation == true + //on which case it is ajax validation, instead of client side + if(!this.validate && this.formNode && this.formNode.onsubmit != null) { var makeRequest = this.formNode.onsubmit.call(evt); if(makeRequest != null && !makeRequest) { this.log("Request canceled by 'onsubmit' of the form"); @@ -22320,9 +22343,14 @@ if(this.showLoading) { this.setContent(this.loadingText); } + + var tmpHref = this.href; + if(!this.ajaxAfterValidation) { + tmpHref = tmpHref + (tmpHref.indexOf("?") > -1 ? "&" : "?") + "validateOnly=true"; + } dojo.io.bind({ - url: this.href, + url: tmpHref, useCache: false, preventCache: true, formNode: self.formNode,
Modified: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/a.ftl URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/a.ftl?view=diff&rev=533389&r1=533388&r2=533389 ============================================================================== --- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/a.ftl (original) +++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/a.ftl Sat Apr 28 09:59:01 2007 @@ -1,4 +1,14 @@ <a dojoType="struts:BindAnchor" + <#if parameters.validate?exists> + validate="${parameters.validate?string?html}"<#rt/> + <#else> + validate="false"<#rt/> + </#if> + <#if parameters.ajaxAfterValidation?exists> + ajaxAfterValidation="${parameters.ajaxAfterValidation?string?html}"<#rt/> + <#else> + ajaxAfterValidation="false" + </#if> <#include "/${parameters.templateDir}/ajax/ajax-common.ftl" /> <#include "/${parameters.templateDir}/simple/scripting-events.ftl" /> <#include "/${parameters.templateDir}/simple/common-attributes.ftl" /> Modified: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/bind.ftl URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/bind.ftl?view=diff&rev=533389&r1=533388&r2=533389 ============================================================================== --- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/bind.ftl (original) +++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/bind.ftl Sat Apr 28 09:59:01 2007 @@ -1,52 +1,74 @@ <script language="JavaScript" type="text/javascript"> dojo.addOnLoad(function() { dojo.widget.createWidget("struts:BindEvent", { - "sources": "${parameters.sources?html}", - "events": "${parameters.events?html}", + "sources": "${parameters.sources?html}",<#rt/> + "events": "${parameters.events?html}",<#rt/> <#if parameters.id?if_exists != ""> - "id": "${parameters.id?html}", + "id": "${parameters.id?html}",<#rt/> </#if> <#if parameters.formId?if_exists != ""> - "formId": "${parameters.formId?html}", + "formId": "${parameters.formId?html}",<#rt/> </#if> <#if parameters.formFilter?if_exists != ""> - "formFilter": "${parameters.formFilter?html}", + "formFilter": "${parameters.formFilter?html}",<#rt/> </#if> <#if parameters.href?if_exists != ""> - "href": "${parameters.href}", + "href": "${parameters.href}",<#rt/> </#if> <#if parameters.loadingText?if_exists != ""> - "loadingText" : "${parameters.loadingText?html}", + "loadingText" : "${parameters.loadingText?html}",<#rt/> </#if> <#if parameters.errorText?if_exists != ""> - "errorText" : "${parameters.errorText?html}", + "errorText" : "${parameters.errorText?html}",<#rt/> </#if> <#if parameters.executeScripts?exists> - "executeScripts": "${parameters.executeScripts?string?html}", + "executeScripts": ${parameters.executeScripts?string?html},<#rt/> </#if> <#if parameters.listenTopics?if_exists != ""> - "listenTopics": "${parameters.listenTopics?html}", + "listenTopics": "${parameters.listenTopics?html}",<#t/> </#if> <#if parameters.notifyTopics?if_exists != ""> - "notifyTopics": "${parameters.notifyTopics?html}", + "notifyTopics": "${parameters.notifyTopics?html}",<#t/> </#if> + <#if parameters.beforeNotifyTopics?if_exists != ""> + "beforeNotifyTopics": "${parameters.beforeNotifyTopics?html}",<#t/> + </#if> + <#if parameters.afterNotifyTopics?if_exists != ""> + "afterNotifyTopics": "${parameters.afterNotifyTopics?html}",<#t/> + </#if> + <#if parameters.errorNotifyTopics?if_exists != ""> + "errorNotifyTopics": "${parameters.errorNotifyTopics?html}",<#t/> + </#if> <#if parameters.targets?if_exists != ""> - "targets": "${parameters.targets?html}", + "targets": "${parameters.targets?html}",<#t/> </#if> <#if parameters.indicator?if_exists != ""> - "indicator": "${parameters.indicator?html}", + "indicator": "${parameters.indicator?html}",<#t/> </#if> <#if parameters.showErrorTransportText?exists> - "showError": "${parameters.showErrorTransportText?string?html}", + "showError": ${parameters.showErrorTransportText?string?html},<#t/> + </#if> + <#if parameters.showLoadingText?exists> + "showLoading": ${parameters.showLoadingText?string?html},<#t/> </#if> <#if parameters.handler?if_exists != ""> - "handler": "${parameters.handler?html}" + "handler": "${parameters.handler?html}",<#t/> </#if> <#if parameters.highlightColor?if_exists != ""> - "highlightColor" : "${parameters.highlightColor?html}"<#rt/> + "highlightColor" : "${parameters.highlightColor?html}",<#t/> </#if> <#if parameters.highlightDuration?if_exists != ""> - "highlightDuration" : "${parameters.highlightDuration?html}"<#rt/> + "highlightDuration" : ${parameters.highlightDuration?html},<#t/> + </#if> + <#if parameters.validate?exists> + "validate": ${parameters.validate?string?html},<#t/> + <#else> + "validate": false, + </#if> + <#if parameters.ajaxAfterValidation?exists> + "ajaxAfterValidation": ${parameters.ajaxAfterValidation?string?html},<#t/> + <#else> + "ajaxAfterValidation": false, </#if> }); }); Modified: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/head.ftl URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/head.ftl?view=diff&rev=533389&r1=533388&r2=533389 ============================================================================== --- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/head.ftl (original) +++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/head.ftl Sat Apr 28 09:59:01 2007 @@ -7,8 +7,8 @@ baseRelativePath: "<@s.url value='${parameters.baseRelativePath}' includeParams='none' encode='false' />", baseScriptUri: "<@s.url value='${parameters.baseRelativePath}' includeParams='none' encode='false' />", <#else> - baseRelativePath: "<@s.url value='/struts/dojo/' includeParams='none' encode='false' />", - baseScriptUri: "<@s.url value='/struts/dojo/' includeParams='none' encode='false' />", + baseRelativePath: "${base}/struts/dojo/", + baseScriptUri: "${base}/struts/dojo/", </#if> <#if parameters.locale?if_exists != ""> locale: "${parameters.locale}", @@ -40,10 +40,14 @@ src="<@s.url value='${parameters.baseRelativePath}/${profile}${dojoFile}' includeParams='none' encode='false' />"></script> <#else> <script language="JavaScript" type="text/javascript" - src="<@s.url value='/struts/dojo/${profile}${dojoFile}' includeParams='none' encode='false' />"></script> + src="${base}/struts/dojo/${profile}${dojoFile}"></script> </#if> <script language="JavaScript" type="text/javascript" - src="<@s.url value='/struts/ajax/dojoRequire.js' includeParams='none' encode='false' />"></script> + src="${base}/struts/ajax/dojoRequire.js"></script> <script language="JavaScript" type="text/javascript" - src="<@s.url value='/struts/CommonFunctions.js' includeParams='none' encode='false'/>"></script> + src="${base}/struts/CommonFunctions.js"></script> +<link rel="stylesheet" href="${base}/struts/xhtml/styles.css" type="text/css"/> +<script language="JavaScript" src="${base}/struts/utils.js" type="text/javascript"></script> +<script language="JavaScript" src="${base}/struts/xhtml/validation.js" type="text/javascript"></script> +<script language="JavaScript" src="${base}/struts/css_xhtml/validation.js" type="text/javascript"></script> \ No newline at end of file Modified: struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/submit.ftl URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/submit.ftl?view=diff&rev=533389&r1=533388&r2=533389 ============================================================================== --- struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/submit.ftl (original) +++ struts/struts2/trunk/plugins/dojo/src/main/resources/template/ajax/submit.ftl Sat Apr 28 09:59:01 2007 @@ -1,3 +1,25 @@ +<#if parameters.parentTheme?default('') == 'xhtml'> + <tr> + <td colspan="2"><div <#rt/> + <#if parameters.align?exists> + align="${parameters.align?html}"<#t/> + </#if> + ><#t/> +<#elseif parameters.parentTheme?default('') == 'css_xhtml'> + <#if parameters.labelposition?default("top") == 'top'> + <div <#rt/> + <#else> + <span <#rt/> + </#if> + <#if parameters.align?exists> + align="${parameters.align?html}"<#t/> + </#if> + <#if parameters.id?exists> + id="wwctrl_${parameters.id}"<#rt/> + </#if> + ><#t/> +</#if> + <#if parameters.type?exists && parameters.type=="button"> <input type="button" dojoType="struts:Bind" events="onclick"<#rt/> <#include "/${parameters.templateDir}/ajax/ajax-common.ftl"/> @@ -25,8 +47,28 @@ <#if parameters.value?if_exists != ""> value="${parameters.value?html}"<#rt/> </#if> + <#if parameters.validate?exists> + validate="${parameters.validate?string?html}"<#rt/> + <#else> + validate="false"<#rt/> + </#if> + <#if parameters.ajaxAfterValidation?exists> + ajaxAfterValidation="${parameters.ajaxAfterValidation?string?html}"<#rt/> + <#else> + ajaxAfterValidation="false" + </#if> <#include "/${parameters.templateDir}/ajax/ajax-common.ftl"/> <#include "/${parameters.templateDir}/simple/scripting-events.ftl" /> <#include "/${parameters.templateDir}/simple/common-attributes.ftl" /> /> </#if> +<#if parameters.parentTheme?default('') == 'xhtml'> + </div><#t/> + <#include "/${parameters.templateDir}/xhtml/controlfooter.ftl" /> +<#elseif parameters.parentTheme?default('') == 'css_xhtml'> + <#if parameters.labelposition?default("top") == 'top'> + </div> <#t/> + <#else> + </span> <#t/> + </#if> +</#if> \ No newline at end of file Modified: struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/dojo/views/jsp/ui/AnchorTest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/dojo/views/jsp/ui/AnchorTest.java?view=diff&rev=533389&r1=533388&r2=533389 ============================================================================== --- struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/dojo/views/jsp/ui/AnchorTest.java (original) +++ struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/dojo/views/jsp/ui/AnchorTest.java Sat Apr 28 09:59:01 2007 @@ -50,6 +50,8 @@ tag.setErrorNotifyTopics("l"); tag.setHighlightColor("m"); tag.setHighlightDuration("n"); + tag.setValidate("true"); + tag.setAjaxAfterValidation("true"); tag.doStartTag(); tag.doEndTag(); Modified: struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/dojo/views/jsp/ui/BindTest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/dojo/views/jsp/ui/BindTest.java?view=diff&rev=533389&r1=533388&r2=533389 ============================================================================== --- struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/dojo/views/jsp/ui/BindTest.java (original) +++ struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/dojo/views/jsp/ui/BindTest.java Sat Apr 28 09:59:01 2007 @@ -26,6 +26,7 @@ tag.setEvents("o"); tag.setHighlightColor("p"); tag.setHighlightDuration("q"); + tag.setValidate("true"); tag.doStartTag(); tag.doEndTag(); Modified: struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/dojo/views/jsp/ui/SubmitAjaxTest.java URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/dojo/views/jsp/ui/SubmitAjaxTest.java?view=diff&rev=533389&r1=533388&r2=533389 ============================================================================== --- struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/dojo/views/jsp/ui/SubmitAjaxTest.java (original) +++ struts/struts2/trunk/plugins/dojo/src/test/java/org/apache/struts2/dojo/views/jsp/ui/SubmitAjaxTest.java Sat Apr 28 09:59:01 2007 @@ -46,6 +46,8 @@ tag.setErrorNotifyTopics("m"); tag.setHighlightColor("n"); tag.setHighlightDuration("o"); + tag.setValidate("true"); + tag.setAjaxAfterValidation("true"); tag.doStartTag(); tag.doEndTag(); @@ -73,6 +75,7 @@ tag.setNotifyTopics("k"); tag.setIndicator("l"); tag.setErrorNotifyTopics("m"); + tag.setValidate("true"); tag.doStartTag(); tag.doEndTag(); @@ -101,6 +104,7 @@ tag.setNotifyTopics("k"); tag.setIndicator("l"); tag.setErrorNotifyTopics("m"); + tag.setValidate("true"); tag.doStartTag(); tag.doEndTag(); Modified: struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/Bind-1.txt URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/Bind-1.txt?view=diff&rev=533389&r1=533388&r2=533389 ============================================================================== --- struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/Bind-1.txt (original) +++ struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/Bind-1.txt Sat Apr 28 09:59:01 2007 @@ -9,11 +9,17 @@ "errorText":"d", "listenTopics":"e", "notifyTopics":"k", + "beforeNotifyTopics":"f", + "afterNotifyTopics":"g", + "errorNotifyTopics":"m", "indicator":"l", - "showError":"true", - "handler":"h" - "highlightColor":"p" - "highlightDuration":"q" + "showError":true, + "showLoading":true, + "handler":"h", + "highlightColor":"p", + "highlightDuration":q, + "validate": true, + "ajaxAfterValidation":false, }); }); </script> Modified: struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/HeadTagTest-1.txt URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/HeadTagTest-1.txt?view=diff&rev=533389&r1=533388&r2=533389 ============================================================================== --- struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/HeadTagTest-1.txt (original) +++ struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/HeadTagTest-1.txt Sat Apr 28 09:59:01 2007 @@ -21,4 +21,15 @@ </script> <script language="JavaScript" type="text/javascript" src="/struts/CommonFunctions.js"> +</script> + +<link rel="stylesheet" href="/struts/xhtml/styles.css" type="text/css"/> + +<script language="JavaScript" src="/struts/utils.js" type="text/javascript"> +</script> + +<script language="JavaScript" src="/struts/xhtml/validation.js" type="text/javascript"> +</script> + +<script language="JavaScript"src="/struts/css_xhtml/validation.js" type="text/javascript"> </script> Modified: struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/HeadTagTest-2.txt URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/HeadTagTest-2.txt?view=diff&rev=533389&r1=533388&r2=533389 ============================================================================== --- struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/HeadTagTest-2.txt (original) +++ struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/HeadTagTest-2.txt Sat Apr 28 09:59:01 2007 @@ -21,4 +21,15 @@ </script> <script language="JavaScript" type="text/javascript" src="/struts/CommonFunctions.js"> +</script> + +<link rel="stylesheet" href="/struts/xhtml/styles.css" type="text/css"/> + +<script language="JavaScript" src="/struts/utils.js" type="text/javascript"> +</script> + +<script language="JavaScript" src="/struts/xhtml/validation.js" type="text/javascript"> +</script> + +<script language="JavaScript"src="/struts/css_xhtml/validation.js" type="text/javascript"> </script> Modified: struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/href-1.txt URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/href-1.txt?view=diff&rev=533389&r1=533388&r2=533389 ============================================================================== --- struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/href-1.txt (original) +++ struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/href-1.txt Sat Apr 28 09:59:01 2007 @@ -1,5 +1,7 @@ <a dojoType="struts:BindAnchor" + validate="true" + ajaxAfterValidation="true" id="mylink" href="a" loadingText="d" Modified: struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/submit-ajax-1.txt URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/submit-ajax-1.txt?view=diff&rev=533389&r1=533388&r2=533389 ============================================================================== --- struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/submit-ajax-1.txt (original) +++ struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/submit-ajax-1.txt Sat Apr 28 09:59:01 2007 @@ -3,6 +3,8 @@ dojoType="struts:Bind" events="onclick" value="Submit" + validate="true" + ajaxAfterValidation="true" id="a" label="i" href="b" Modified: struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/submit-ajax-3.txt URL: http://svn.apache.org/viewvc/struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/submit-ajax-3.txt?view=diff&rev=533389&r1=533388&r2=533389 ============================================================================== --- struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/submit-ajax-3.txt (original) +++ struts/struts2/trunk/plugins/dojo/src/test/resources/org/apache/struts2/dojo/views/jsp/ui/submit-ajax-3.txt Sat Apr 28 09:59:01 2007 @@ -5,6 +5,8 @@ alt="i" src="j" value="Submit" + validate="true" + ajaxAfterValidation="false" id="a" label="i" href="b"