diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientDateValidator.java b/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientDateValidator.java
index a3bc5c01..9ebad722 100644
--- a/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientDateValidator.java
+++ b/spring-faces/src/main/java/org/springframework/faces/ui/DojoClientDateValidator.java
@@ -15,6 +15,12 @@
*/
package org.springframework.faces.ui;
+import javax.faces.component.ValueHolder;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.DateTimeConverter;
+
+import org.springframework.util.Assert;
+
/**
* Component that uses the Dojo implementation of Spring JavaScript to decorate a child input component with client-side
* date validation behavior.
@@ -26,12 +32,52 @@ public class DojoClientDateValidator extends DojoDecoration {
private static final String DOJO_COMPONENT_TYPE = "dijit.form.DateTextBox";
+ private static final String[] DOJO_ATTRS_INTERNAL = new String[] { "datePattern" };
+
+ private static final String[] DOJO_ATTRS;
+
+ private String datePattern = null;
+
+ static {
+ DOJO_ATTRS = new String[DojoDecoration.DOJO_ATTRS.length + DOJO_ATTRS_INTERNAL.length];
+ System.arraycopy(DojoDecoration.DOJO_ATTRS, 0, DOJO_ATTRS, 0, DojoDecoration.DOJO_ATTRS.length);
+ System.arraycopy(DOJO_ATTRS_INTERNAL, 0, DOJO_ATTRS, DojoDecoration.DOJO_ATTRS.length,
+ DOJO_ATTRS_INTERNAL.length);
+ }
+
+ public String getDatePattern() {
+ Assert.isTrue(getChildren().get(0) instanceof ValueHolder,
+ "Date validation can only be applied to an ValueHolder");
+ ValueHolder child = (ValueHolder) getChildren().get(0);
+ if (child.getConverter() instanceof DateTimeConverter) {
+ return ((DateTimeConverter) child.getConverter()).getPattern();
+ }
+ return datePattern;
+ }
+
+ public void setDatePattern(String datePattern) {
+ this.datePattern = datePattern;
+ }
+
protected String[] getDojoAttributes() {
- return DojoDecoration.DOJO_ATTRS;
+ return DOJO_ATTRS;
}
public String getDojoComponentType() {
return DOJO_COMPONENT_TYPE;
}
+ public Object saveState(FacesContext context) {
+ Object[] values = new Object[2];
+ values[0] = super.saveState(context);
+ values[1] = this.datePattern;
+ return values;
+ }
+
+ public void restoreState(FacesContext context, Object state) {
+ Object values[] = (Object[]) state;
+ super.restoreState(context, values[0]);
+ this.datePattern = (String) values[1];
+ }
+
}
diff --git a/spring-faces/src/main/java/org/springframework/faces/ui/DojoDecorationRenderer.java b/spring-faces/src/main/java/org/springframework/faces/ui/DojoDecorationRenderer.java
index 4d0323e5..0974af17 100644
--- a/spring-faces/src/main/java/org/springframework/faces/ui/DojoDecorationRenderer.java
+++ b/spring-faces/src/main/java/org/springframework/faces/ui/DojoDecorationRenderer.java
@@ -16,18 +16,14 @@
package org.springframework.faces.ui;
import java.io.IOException;
-import java.util.Date;
import javax.faces.FacesException;
import javax.faces.component.UIComponent;
-import javax.faces.component.ValueHolder;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
-import javax.faces.convert.Converter;
import org.springframework.faces.ui.resource.ResourceHelper;
import org.springframework.faces.webflow.JsfUtils;
-import org.springframework.util.StringUtils;
/**
* Generic renderer for components that use the Dojo implementation of Spring JavaScript to decorate a child component
@@ -78,13 +74,8 @@ public class DojoDecorationRenderer extends BaseSpringJavascriptDecorationRender
script.append(" widgetType : '" + ((DojoDecoration) component).getDojoComponentType() + "', ");
script.append(" widgetAttrs : { ");
- String nodeAttrs = getNodeAttributesAsString(context, advisedChild);
String dojoAttrs = getDojoAttributesAsString(context, component);
- script.append(nodeAttrs);
- if (StringUtils.hasText(dojoAttrs)) {
- script.append(", ");
- }
script.append(dojoAttrs);
script.append(" }}));");
@@ -94,50 +85,6 @@ public class DojoDecorationRenderer extends BaseSpringJavascriptDecorationRender
ResourceHelper.endScriptBlock(context);
}
- protected String getNodeAttributesAsString(FacesContext context, UIComponent component) {
-
- StringBuffer attrs = new StringBuffer();
-
- attrs.append("name : '" + component.getClientId(context) + "'");
-
- ValueHolder valueHolder = (ValueHolder) component;
-
- if (valueHolder.getValue() != null) {
- attrs.append(", value : ");
- String strValue = "'" + getValueAsString(context, component) + "'";
- if (valueHolder.getValue() instanceof Date) {
- strValue = "dojo.date.locale.parse(" + strValue + ", {selector : 'date', datePattern : 'yyyy-MM-dd'})";
- }
- attrs.append(strValue);
- }
-
- return attrs.toString();
- }
-
- protected String getValueAsString(FacesContext context, UIComponent component) {
-
- ValueHolder valueHolder = (ValueHolder) component;
-
- if (valueHolder.getValue() instanceof String) {
- return valueHolder.getValue().toString();
- }
-
- Converter converter;
- if (valueHolder.getConverter() != null) {
- converter = valueHolder.getConverter();
- } else {
- converter = context.getApplication().createConverter(valueHolder.getValue().getClass());
- }
-
- if (converter == null) {
- throw new FacesException("A converter could not be found to convert the value of " + component
- + " to a String.");
- }
-
- return converter.getAsString(context, component, valueHolder.getValue());
-
- }
-
protected String getDojoAttributesAsString(FacesContext context, UIComponent component) {
DojoDecoration advisor = (DojoDecoration) component;
diff --git a/spring-faces/src/test/java/org/springframework/faces/ui/DojoDecorationRendererTests.java b/spring-faces/src/test/java/org/springframework/faces/ui/DojoDecorationRendererTests.java
deleted file mode 100644
index 31061bf1..00000000
--- a/spring-faces/src/test/java/org/springframework/faces/ui/DojoDecorationRendererTests.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package org.springframework.faces.ui;
-
-import java.util.Calendar;
-import java.util.Locale;
-
-import javax.faces.FacesException;
-import javax.faces.component.UIInput;
-import javax.faces.convert.DateTimeConverter;
-
-import junit.framework.TestCase;
-
-import org.springframework.faces.webflow.JSFMockHelper;
-
-public class DojoDecorationRendererTests extends TestCase {
-
- JSFMockHelper jsf = new JSFMockHelper();
-
- public void setUp() throws Exception {
- jsf.setUp();
- }
-
- public void tearDown() throws Exception {
- jsf.tearDown();
- }
-
- public void testGetValueAsString() {
- UIInput childComponent = new UIInput();
- childComponent.setValue("foo");
- DojoDecorationRenderer renderer = new DojoDecorationRenderer();
- String convertedValue = renderer.getValueAsString(jsf.facesContext(), childComponent);
- assertEquals("foo", convertedValue);
- }
-
- public void testGetValueAsString_LocalConverter() {
- UIInput childComponent = new UIInput();
- childComponent.setValue(new TestValue());
- childComponent.setConverter(new TestConverter());
- DojoDecorationRenderer renderer = new DojoDecorationRenderer();
- String convertedValue = renderer.getValueAsString(jsf.facesContext(), childComponent);
- assertEquals("foo", convertedValue);
- }
-
- public void testGetValueAsString_NoConverter() {
- UIInput childComponent = new UIInput();
- childComponent.setValue(new TestValue());
- DojoDecorationRenderer renderer = new DojoDecorationRenderer();
- try {
- renderer.getValueAsString(jsf.facesContext(), childComponent);
- fail("getValueAsString should throw exception if no converter is found");
- } catch (FacesException ex) {
- // expected
- }
- }
-
- public void testGetValueAsString_GlobalConverter() throws Exception {
- UIInput childComponent = new UIInput();
- childComponent.setValue(new TestValue());
- jsf.facesContext().getApplication().addConverter(TestValue.class, TestConverter.class.getName());
- DojoDecorationRenderer renderer = new DojoDecorationRenderer();
- String convertedValue = renderer.getValueAsString(jsf.facesContext(), childComponent);
- assertEquals("foo", convertedValue);
- }
-
- public void testGetNodeAttributesAsString() {
- String expectedAttributes = "name : 'foo', value : 'foo'";
- UIInput childComponent = new UIInput();
- childComponent.setId("foo");
- childComponent.setValue("foo");
- DojoDecorationRenderer renderer = new DojoDecorationRenderer();
- String nodeAttributes = renderer.getNodeAttributesAsString(jsf.facesContext(), childComponent);
- assertEquals(expectedAttributes, nodeAttributes);
- }
-
- public void testGetNodeAttributesAsString_DateValue() {
- String expectedAttributes = "name : 'foo', value : dojo.date.locale.parse('Nov 21, 1977', "
- + "{selector : 'date', datePattern : 'yyyy-MM-dd'})";
- UIInput childComponent = new UIInput();
- DateTimeConverter converter = new DateTimeConverter();
- converter.setLocale(Locale.US);
- childComponent.setConverter(converter);
- childComponent.setId("foo");
- Calendar cal = Calendar.getInstance(Locale.US);
- cal.set(1977, Calendar.NOVEMBER, 21, 12, 0);
- childComponent.setValue(cal.getTime());
- DojoDecorationRenderer renderer = new DojoDecorationRenderer();
- String nodeAttributes = renderer.getNodeAttributesAsString(jsf.facesContext(), childComponent);
- assertEquals(expectedAttributes, nodeAttributes);
- }
-}
diff --git a/spring-js/src/main/resources/META-INF/spring/Spring-Dojo.js b/spring-js/src/main/resources/META-INF/spring/Spring-Dojo.js
index f9d90ec8..3937a04e 100644
--- a/spring-js/src/main/resources/META-INF/spring/Spring-Dojo.js
+++ b/spring-js/src/main/resources/META-INF/spring/Spring-Dojo.js
@@ -13,4 +13,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-dojo.declare("Spring.DefaultEquals",null,{equals:function(_1){if(_1.declaredClass&&_1.declaredClass==this.declaredClass){return true;}else{return false;}}});dojo.declare("Spring.ElementDecoration",[Spring.AbstractElementDecoration,Spring.DefaultEquals],{constructor:function(_2){this.copyFields=new Array("name","value","type","checked","selected","readOnly","disabled","alt","maxLength","class","title");dojo.mixin(this,_2);if(this.widgetModule==""){this.widgetModule=this.widgetType;}},apply:function(){if(dijit.byId(this.elementId)){dijit.byId(this.elementId).destroyRecursive(false);}var _3=dojo.byId(this.elementId);if(!_3){console.error("Could not apply "+this.widgetType+" decoration. Element with id '"+this.elementId+"' not found in the DOM.");}else{for(var _4 in this.copyFields){_4=this.copyFields[_4];if(!this.widgetAttrs[_4]&&_3[_4]&&(typeof _3[_4]!="number"||(typeof _3[_4]=="number"&&_3[_4]>=0))){this.widgetAttrs[_4]=_3[_4];}}if(_3["style"]&&_3["style"].cssText){this.widgetAttrs["style"]=_3["style"].cssText;}dojo.require(this.widgetModule);var _5=dojo.eval(this.widgetType);this.widget=new _5(this.widgetAttrs,_3);this.widget.startup();}return this;},validate:function(){if(!this.widget.isValid){return true;}var _6=this.widget.isValid(false);if(!_6){this.widget.state="Error";this.widget._setStateClass();}return _6;}});dojo.declare("Spring.ValidateAllDecoration",[Spring.AbstractValidateAllDecoration,Spring.DefaultEquals],{constructor:function(_7){this.originalHandler=null;this.connection=null;dojo.mixin(this,_7);},apply:function(){var _8=dojo.byId(this.elementId);this.originalHandler=_8[this.event];var _9=this;_8[this.event]=function(_a){_9.handleEvent(_a,_9);};return this;},cleanup:function(){dojo.disconnect(this.connection);},handleEvent:function(_b,_c){if(!Spring.validateAll()){dojo.stopEvent(_b);}else{if(dojo.isFunction(_c.originalHandler)){var _d=_c.originalHandler(_b);if(_d==false){dojo.stopEvent(_b);}}}}});dojo.declare("Spring.AjaxEventDecoration",[Spring.AbstractAjaxEventDecoration,Spring.DefaultEquals],{constructor:function(_e){this.connection=null;dojo.mixin(this,_e);},apply:function(){this.connection=dojo.connect(dojo.byId(this.elementId),this.event,this,"submit");return this;},cleanup:function(){dojo.disconnect(this.connection);},submit:function(_f){if(this.sourceId==""){this.sourceId=this.elementId;}if(this.formId==""){Spring.remoting.getLinkedResource(this.sourceId,this.params,this.popup);}else{Spring.remoting.submitForm(this.sourceId,this.formId,this.params);}dojo.stopEvent(_f);}});dojo.declare("Spring.RemotingHandler",Spring.AbstractRemotingHandler,{constructor:function(){},submitForm:function(_10,_11,_12){var _13=new Object();for(var key in _12){_13[key]=_12[key];}var _15=dojo.byId(_10);if(_15!=null){if(_15.value!=undefined&&_15.type&&("button,submit,reset").indexOf(_15.type)<0){_13[_10]=_15.value;}else{if(_15.name!=undefined){_13[_15.name]=_15.name;}else{_13[_10]=_10;}}}if(!_13["ajaxSource"]){_13["ajaxSource"]=_10;}dojo.xhrPost({content:_13,form:_11,handleAs:"text",headers:{"Accept":"text/html;type=ajax"},load:this.handleResponse,error:this.handleError});},getLinkedResource:function(_16,_17,_18){this.getResource(dojo.byId(_16).href,_17,_18);},getResource:function(_19,_1a,_1b){dojo.xhrGet({url:_19,content:_1a,handleAs:"text",headers:{"Accept":"text/html;type=ajax"},load:this.handleResponse,error:this.handleError,modal:_1b});},handleResponse:function(_1c,_1d){var _1e=_1d.xhr.getResponseHeader("Spring-Redirect-URL");var _1f=_1d.xhr.getResponseHeader("Spring-Modal-View");var _20=((dojo.isString(_1f)&&_1f.length>0)||_1d.args.modal);if(dojo.isString(_1e)&&_1e.length>0){if(_20){Spring.remoting.renderURLToModalDialog(_1e,_1d);return _1c;}else{if(_1e.indexOf("/")>=0){window.location=window.location.protocol+"//"+window.location.host+_1e;}else{var _21=window.location.protocol+"//"+window.location.host+window.location.pathname;var _22=_21.lastIndexOf("/");_21=_21.substr(0,_22+1)+_1e;if(_21==window.location){Spring.remoting.getResource(_21,_1d.args.content,false);}else{window.location=_21;}}return _1c;}}var _23="(?:)";var _24=[];var _25=new RegExp(_23,"img");var _26=new RegExp(_23,"im");var _27=_1c.match(_25);if(_27!=null){for(var i=0;i<_27.length;i++){var _29=(_27[i].match(_26)||["","",""])[2];_29=_29.replace(//mg,"").replace(/)*/mg,"").replace(/(/mg,"");_24.push(_29);}}_1c=_1c.replace(_25,"");var _2a=dojo.doc.createElement("span");_2a.id="ajaxResponse";_2a.style.visibility="hidden";document.body.appendChild(_2a);_2a.innerHTML=_1c;var _2b=new dojo.NodeList(_2a);var _2c=_2b.query("#ajaxResponse > *").orphan();_2b.orphan();if(_20){Spring.remoting.renderNodeListToModalDialog(_2c);}else{_2c.forEach(function(_2d){if(_2d.id!=null&&_2d.id!=""){var _2e=dojo.byId(_2d.id);if(!_2e){console.error("An existing DOM elment with id '"+_2d.id+"' could not be found for replacement.");}else{_2e.parentNode.replaceChild(_2d,_2e);}}});}dojo.forEach(_24,function(_2f){dojo.eval(_2f);});return _1c;},handleError:function(_30,_31){dojo.require("dijit.Dialog");console.error("HTTP status code: ",_31.xhr.status);if(Spring.debug&&_31.xhr.status!=200){var _32=new dijit.Dialog({});dojo.connect(_32,"hide",_32,function(){this.destroyRecursive(false);});_32.domNode.style.width="80%";_32.domNode.style.height="80%";_32.domNode.style.textAlign="left";_32.setContent(_31.xhr.responseText);_32.show();}return _30;},renderURLToModalDialog:function(url,_34){url=url+"&"+dojo.objectToQuery(_34.args.content);Spring.remoting.getResource(url,{},true);},renderNodeListToModalDialog:function(_35){dojo.require("dijit.Dialog");var _36=new dijit.Dialog({});_36.setContent(_35);dojo.connect(_36,"hide",_36,function(){this.destroyRecursive(false);});_36.show();}});dojo.declare("Spring.CommandLinkDecoration",[Spring.AbstractCommandLinkDecoration,Spring.DefaultEquals],{constructor:function(_37){dojo.mixin(this,_37);},apply:function(){var _38=dojo.byId(this.elementId);if(!dojo.hasClass(_38,"progressiveLink")){var _39=new dojo.NodeList(_38);_39.addContent(this.linkHtml,"after").orphan("*");_38=dojo.byId(this.elementId);}_38.submitFormFromLink=this.submitFormFromLink;return this;},submitFormFromLink:function(_3a,_3b,_3c){var _3d=[];var _3e=dojo.byId(_3a);var _3f=document.createElement("input");_3f.name=_3b;_3f.value="submitted";_3d.push(_3f);dojo.forEach(_3c,function(_40){var _41=document.createElement("input");_41.name=_40.name;_41.value=_40.value;_3d.push(_41);});dojo.forEach(_3d,function(_42){dojo.addClass(_42,"SpringLinkInput");dojo.place(_42,_3e,"last");});if((_3e.onsubmit?!_3e.onsubmit():false)||!_3e.submit()){dojo.forEach(_3d,function(_43){_3e.removeChild(_43);});}}});dojo.addOnLoad(Spring.initialize);
\ No newline at end of file
+dojo.declare("Spring.DefaultEquals",null,{equals:function(_1){if(_1.declaredClass&&_1.declaredClass==this.declaredClass){return true;}else{return false;}}});dojo.declare("Spring.ElementDecoration",[Spring.AbstractElementDecoration,Spring.DefaultEquals],{constructor:function(_2){this.copyFields=new Array("name","value","type","checked","selected","readOnly","disabled","alt","maxLength","class","title");dojo.mixin(this,_2);if(this.widgetModule==""){this.widgetModule=this.widgetType;}},apply:function(){if(dijit.byId(this.elementId)){dijit.byId(this.elementId).destroyRecursive(false);}var _3=dojo.byId(this.elementId);if(!_3){console.error("Could not apply "+this.widgetType+" decoration. Element with id '"+this.elementId+"' not found in the DOM.");}else{var _4=this.widgetAttrs["datePattern"];if(_4&&this.widgetType=="dijit.form.DateTextBox"){if(!this.widgetAttrs["value"]){this.widgetAttrs["value"]=dojo.date.locale.parse(_3.value,{selector:"date",datePattern:_4});}if(!this.widgetAttrs["serialize"]){this.widgetAttrs["serialize"]=function(d,_6){return dojo.date.locale.format(d,{selector:"date",datePattern:_4});};}}for(var _7 in this.copyFields){_7=this.copyFields[_7];if(!this.widgetAttrs[_7]&&_3[_7]&&(typeof _3[_7]!="number"||(typeof _3[_7]=="number"&&_3[_7]>=0))){this.widgetAttrs[_7]=_3[_7];}}if(_3["style"]&&_3["style"].cssText){this.widgetAttrs["style"]=_3["style"].cssText;}dojo.require(this.widgetModule);var _8=dojo.eval(this.widgetType);this.widget=new _8(this.widgetAttrs,_3);this.widget.startup();}return this;},validate:function(){if(!this.widget.isValid){return true;}var _9=this.widget.isValid(false);if(!_9){this.widget.state="Error";this.widget._setStateClass();}return _9;}});dojo.declare("Spring.ValidateAllDecoration",[Spring.AbstractValidateAllDecoration,Spring.DefaultEquals],{constructor:function(_a){this.originalHandler=null;this.connection=null;dojo.mixin(this,_a);},apply:function(){var _b=dojo.byId(this.elementId);this.originalHandler=_b[this.event];var _c=this;_b[this.event]=function(_d){_c.handleEvent(_d,_c);};return this;},cleanup:function(){dojo.disconnect(this.connection);},handleEvent:function(_e,_f){_e.springValidateAll=Spring.validateAll();if(!_e.springValidateAll){dojo.stopEvent(_e);}else{if(dojo.isFunction(_f.originalHandler)){var _10=_f.originalHandler(_e);if(_10==false){dojo.stopEvent(_e);}}}}});dojo.declare("Spring.AjaxEventDecoration",[Spring.AbstractAjaxEventDecoration,Spring.DefaultEquals],{constructor:function(_11){this.connection=null;dojo.mixin(this,_11);},apply:function(){this.connection=dojo.connect(dojo.byId(this.elementId),this.event,this,"submit");return this;},cleanup:function(){dojo.disconnect(this.connection);},submit:function(_12){if(this.sourceId==""){this.sourceId=this.elementId;}if(this.formId==""){Spring.remoting.getLinkedResource(this.sourceId,this.params,this.popup);}else{if(_12.springValidateAll){Spring.remoting.submitForm(this.sourceId,this.formId,this.params);}}dojo.stopEvent(_12);}});dojo.declare("Spring.RemotingHandler",Spring.AbstractRemotingHandler,{constructor:function(){},submitForm:function(_13,_14,_15){var _16=new Object();for(var key in _15){_16[key]=_15[key];}var _18=dojo.byId(_13);if(_18!=null){if(_18.value!=undefined&&_18.type&&("button,submit,reset").indexOf(_18.type)<0){_16[_13]=_18.value;}else{if(_18.name!=undefined){_16[_18.name]=_18.name;}else{_16[_13]=_13;}}}if(!_16["ajaxSource"]){_16["ajaxSource"]=_13;}dojo.xhrPost({content:_16,form:_14,handleAs:"text",headers:{"Accept":"text/html;type=ajax"},load:this.handleResponse,error:this.handleError});},getLinkedResource:function(_19,_1a,_1b){this.getResource(dojo.byId(_19).href,_1a,_1b);},getResource:function(_1c,_1d,_1e){dojo.xhrGet({url:_1c,content:_1d,handleAs:"text",headers:{"Accept":"text/html;type=ajax"},load:this.handleResponse,error:this.handleError,modal:_1e});},handleResponse:function(_1f,_20){var _21=_20.xhr.getResponseHeader("Spring-Redirect-URL");var _22=_20.xhr.getResponseHeader("Spring-Modal-View");var _23=((dojo.isString(_22)&&_22.length>0)||_20.args.modal);if(dojo.isString(_21)&&_21.length>0){if(_23){Spring.remoting.renderURLToModalDialog(_21,_20);return _1f;}else{if(_21.indexOf("/")>=0){window.location=window.location.protocol+"//"+window.location.host+_21;}else{var _24=window.location.protocol+"//"+window.location.host+window.location.pathname;var _25=_24.lastIndexOf("/");_24=_24.substr(0,_25+1)+_21;if(_24==window.location){Spring.remoting.getResource(_24,_20.args.content,false);}else{window.location=_24;}}return _1f;}}var _26="(?:)";var _27=[];var _28=new RegExp(_26,"img");var _29=new RegExp(_26,"im");var _2a=_1f.match(_28);if(_2a!=null){for(var i=0;i<_2a.length;i++){var _2c=(_2a[i].match(_29)||["","",""])[2];_2c=_2c.replace(//mg,"").replace(/)*/mg,"").replace(/(/mg,"");_27.push(_2c);}}_1f=_1f.replace(_28,"");var _2d=dojo.doc.createElement("span");_2d.id="ajaxResponse";_2d.style.visibility="hidden";document.body.appendChild(_2d);_2d.innerHTML=_1f;var _2e=new dojo.NodeList(_2d);var _2f=_2e.query("#ajaxResponse > *").orphan();_2e.orphan();if(_23){Spring.remoting.renderNodeListToModalDialog(_2f);}else{_2f.forEach(function(_30){if(_30.id!=null&&_30.id!=""){var _31=dojo.byId(_30.id);if(!_31){console.error("An existing DOM elment with id '"+_30.id+"' could not be found for replacement.");}else{_31.parentNode.replaceChild(_30,_31);}}});}dojo.forEach(_27,function(_32){dojo.eval(_32);});return _1f;},handleError:function(_33,_34){dojo.require("dijit.Dialog");console.error("HTTP status code: ",_34.xhr.status);if(Spring.debug&&_34.xhr.status!=200){var _35=new dijit.Dialog({});dojo.connect(_35,"hide",_35,function(){this.destroyRecursive(false);});_35.domNode.style.width="80%";_35.domNode.style.height="80%";_35.domNode.style.textAlign="left";_35.setContent(_34.xhr.responseText);_35.show();}return _33;},renderURLToModalDialog:function(url,_37){url=url+"&"+dojo.objectToQuery(_37.args.content);Spring.remoting.getResource(url,{},true);},renderNodeListToModalDialog:function(_38){dojo.require("dijit.Dialog");var _39=new dijit.Dialog({});_39.setContent(_38);dojo.connect(_39,"hide",_39,function(){this.destroyRecursive(false);});_39.show();}});dojo.declare("Spring.CommandLinkDecoration",[Spring.AbstractCommandLinkDecoration,Spring.DefaultEquals],{constructor:function(_3a){dojo.mixin(this,_3a);},apply:function(){var _3b=dojo.byId(this.elementId);if(!dojo.hasClass(_3b,"progressiveLink")){var _3c=new dojo.NodeList(_3b);_3c.addContent(this.linkHtml,"after").orphan("*");_3b=dojo.byId(this.elementId);}_3b.submitFormFromLink=this.submitFormFromLink;return this;},submitFormFromLink:function(_3d,_3e,_3f){var _40=[];var _41=dojo.byId(_3d);var _42=document.createElement("input");_42.name=_3e;_42.value="submitted";_40.push(_42);dojo.forEach(_3f,function(_43){var _44=document.createElement("input");_44.name=_43.name;_44.value=_43.value;_40.push(_44);});dojo.forEach(_40,function(_45){dojo.addClass(_45,"SpringLinkInput");dojo.place(_45,_41,"last");});if((_41.onsubmit?!_41.onsubmit():false)||!_41.submit()){dojo.forEach(_40,function(_46){_41.removeChild(_46);});}}});dojo.addOnLoad(Spring.initialize);
\ No newline at end of file
diff --git a/spring-js/src/main/resources/META-INF/spring/Spring-Dojo.js.uncompressed.js b/spring-js/src/main/resources/META-INF/spring/Spring-Dojo.js.uncompressed.js
index ec07db2d..0bd55de8 100644
--- a/spring-js/src/main/resources/META-INF/spring/Spring-Dojo.js.uncompressed.js
+++ b/spring-js/src/main/resources/META-INF/spring/Spring-Dojo.js.uncompressed.js
@@ -41,6 +41,17 @@ dojo.declare("Spring.ElementDecoration", [Spring.AbstractElementDecoration, Spri
console.error("Could not apply " + this.widgetType + " decoration. Element with id '" + this.elementId + "' not found in the DOM.");
}
else {
+ var datePattern = this.widgetAttrs['datePattern'];
+ if (datePattern && this.widgetType == 'dijit.form.DateTextBox') {
+ if (!this.widgetAttrs['value']) {
+ this.widgetAttrs['value'] = dojo.date.locale.parse(element.value, {selector : "date", datePattern : datePattern});
+ }
+ if (!this.widgetAttrs['serialize']) {
+ this.widgetAttrs['serialize'] = function(d, options){
+ return dojo.date.locale.format(d, {selector : "date", datePattern : datePattern});
+ }
+ }
+ }
for (var copyField in this.copyFields) {
copyField = this.copyFields[copyField];
if (!this.widgetAttrs[copyField] && element[copyField] &&
@@ -97,7 +108,8 @@ dojo.declare("Spring.ValidateAllDecoration", [Spring.AbstractValidateAllDecorati
},
handleEvent : function(event, context){
- if (!Spring.validateAll()) {
+ event.springValidateAll = Spring.validateAll();
+ if (!event.springValidateAll) {
dojo.stopEvent(event);
} else if(dojo.isFunction(context.originalHandler)) {
var result = context.originalHandler(event);
@@ -130,7 +142,9 @@ dojo.declare("Spring.AjaxEventDecoration", [Spring.AbstractAjaxEventDecoration,
if(this.formId == ""){
Spring.remoting.getLinkedResource(this.sourceId, this.params, this.popup);
} else {
- Spring.remoting.submitForm(this.sourceId, this.formId, this.params);
+ if (event.springValidateAll){
+ Spring.remoting.submitForm(this.sourceId, this.formId, this.params);
+ }
}
dojo.stopEvent(event);
}
diff --git a/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/flows/booking/enterBookingDetails.xhtml b/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/flows/booking/enterBookingDetails.xhtml
index c533c4ae..db11a27d 100644
--- a/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/flows/booking/enterBookingDetails.xhtml
+++ b/spring-webflow-samples/booking-faces/src/main/webapp/WEB-INF/flows/booking/enterBookingDetails.xhtml
@@ -50,9 +50,9 @@