Hi,
For see same result type below lines in the Roo console :
Two things about generated code :Code:entity --class ~.domain.FooBar field date --fieldName today --type java.util.Date --class ~.domain.FooBar controller scaffold --class ~.web.FooBarController
create.jspx
First if we remove the scripts and submit the form with invalid date pattern then you will see below exceptions :Code:<div id="roo_foobar_today"> <label for="_today_id">Today:</label> <form:input cssStyle="width:250px" id="_today_id" maxlength="30" path="today" size="0"/> <br/> <form:errors cssClass="errors" id="_today_error_id" path="today"/> <spring:message arguments="Today" code="field.invalid" var="field_invalid"/> <spring:message code="field.required" var="field_required"/> <spring:message argumentSeparator="," arguments="Today," code="field.simple.validation" var="field_validation"/> <script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : '_today_id', widgetType : 'dijit.form.ValidationTextBox', widgetAttrs : {promptMessage: '${field_validation}', invalidMessage: '${field_invalid}', required : false}})); </script> <script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : '_today_id', widgetType : 'dijit.form.DateTextBox', widgetAttrs : {promptMessage: '${field_validation}', constraints: {datePattern : '${foobar_today_date_format}', required : false}, datePattern : '${foobar_today_date_format}'}})); </script> </div>
for fix this I need to change below parts :Code:java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'foobar' available as request attribute at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:141) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:175) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:195) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:161) at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:124) at org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:409) at org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:140) at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:91) at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:78) ... IO Error executing tag: JSPException including path '/WEB-INF/views/foobar/create.jspx'. org.apache.tiles.util.TilesIOException: JSPException including path '/WEB-INF/views/foobar/create.jspx'. at org.apache.tiles.servlet.context.ServletUtil.wrapServletException(ServletUtil.java:232) at org.apache.tiles.jsp.context.JspTilesRequestContext.include(JspTilesRequestContext.java:105) at org.apache.tiles.jsp.context.JspTilesRequestContext.dispatch(JspTilesRequestContext.java:96) at org.apache.tiles.renderer.impl.UntypedAttributeRenderer.write(UntypedAttributeRenderer.java:61) at org.apache.tiles.renderer.impl.AbstractBaseAttributeRenderer.render(AbstractBaseAttributeRenderer.java:103) at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:669) at org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.java:337) at org.apache.tiles.jsp.taglib.InsertAttributeTag.render(InsertAttributeTag.java:234) at org.apache.tiles.jsp.taglib.InsertAttributeTag.render(InsertAttributeTag.java:211) at org.apache.tiles.jsp.taglib.RenderTag.doEndTag(RenderTag.java:220) ....
create.jspx
FooBarController_Roo_Controller.ajCode:<form:form action="${form_url}" method="POST" modelAttribute="fooBar">
Second thing is not much important : I found out below script code would act same as two lines scripts code for date fields :Code:@RequestMapping(value = "/foobar/form", method = RequestMethod.GET) public String FooBarController.createForm(ModelMap modelMap) { modelMap.addAttribute("fooBar", new FooBar()); modelMap.addAttribute("foobar_today_date_format", org.joda.time.format.DateTimeFormat.patternForStyle("S-", org.springframework.context.i18n.LocaleContextHolder.getLocale())); return "foobar/create"; }
My current issue is I have to set automaticallyMaintainView to the false in FooBarController !Code:<script type="text/javascript">Spring.addDecoration(new Spring.ElementDecoration({elementId : '_today_id', widgetType : 'dijit.form.DateTextBox', widgetAttrs : {promptMessage: '${field_validation}', invalidMessage: '${field_invalid}', required : false, datePattern : '${foobar_today_date_format}'}})); </script>
Cheers,
Sid
ps. Roo is awesome :-)


Reply With Quote