icfnext / cq-component-maven-plugin

Other
22 stars 35 forks source link

DateField Annotation default storedFormat error #26

Closed jmolsen closed 7 years ago

jmolsen commented 8 years ago

For pages with @DateField properties, when creating a page and setting a date during the creation process in the TouchUI, the following error shows up in the error.log in addition to the UI error message that pops up when attempting to save the page: ERROR [0:0:0:0:0:0:0:1 [1447362379123] POST /libs/wcm/core/content/sites/createpagewizard/_jcr_content HTTP/1.1] libs.cq.gui.components.siteadmin.admin.createpagewizard.page.POST$jsp Error occur creating a new page javax.jcr.ValueFormatException: Invalid date 2015-11-12 at org.apache.jackrabbit.oak.plugins.value.ValueFactoryImpl.createValue(ValueFactoryImpl.java:232) at org.apache.jackrabbit.oak.jcr.session.NodeImpl.setProperty(NodeImpl.java:441) at org.apache.jsp.libs.cq.gui.components.siteadmin.admin.createpagewizard.page.POST_jsp.writeContent(POST_jsp.java:124)

In ValueFactoryImpl.createValue it looks like it's running the following for dates: if (ISO8601.parse(value) == null) { throw new ValueFormatException("Invalid date " + value); }

Currently, the DateField is set with the default storedFormat = "YYYY-MM-DD". You can test how this fails in the groovy console: (org.apache.jackrabbit.util.ISO8601.parse("2015-11-12") == null) ? "FAIL" : "SUCCESS"

However, the following succeeds: (org.apache.jackrabbit.util.ISO8601.parse("2015-11-12T00:00:00.000-06:00") == null) ? "FAIL" : "SUCCESS"

If I update the DateField annotation to override the storedFormat then the page can be created without the error: @DateField(storedFormat="YYYY-MM-DDThh:mm:ss.SSSZ")

So, for now we can override the storedFormat, but I'm guessing we probably want to change the default in the DateField annotation.

michaelhodgdon commented 7 years ago

Closing as this was completed