Dear Members
I am trying to reuse my PropertyEditorRegistrar and PropertyEditorSupport used with Spring MVC for SWF 2.0.x
Below all my code
where for example a PropertyEditorSupport has the follow structureCode:@Component("controlprematriculapropertyeditorregistrar") public class ControlPreMatriculaPropertyEditorRegistrar implements PropertyEditorRegistrar { private static final Logger logger = LoggerFactory.getLogger(ControlPreMatriculaPropertyEditorRegistrar.class); public void registerCustomEditors(PropertyEditorRegistry registry) { SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); dateFormat.setLenient(false); registry.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false)); registry.registerCustomEditor(ControlPreMatricula.class, new ControlPreMatriculaPropertyEditorSupport()); registry.registerCustomEditor(Local.class, new LocalPropertyEditorSupport()); registry.registerCustomEditor(Curso.class, new CursoPropertyEditorSupport()); registry.registerCustomEditor(TipoTurno.class, new TipoTurnoPropertyEditorSupport()); registry.registerCustomEditor(Turno.class, new TurnoPropertyEditorSupport()); } }
Where such class isCode:@Component("localpropertyeditorsupport") public class LocalPropertyEditorSupport extends PropertyEditorSupport{ private static final Logger logger = LoggerFactory.getLogger(LocalPropertyEditorSupport.class); private LocalBoService localBoService; @Autowired @Qualifier("localbo") public void setLocalBoService(LocalBoService localBoService) { this.localBoService = localBoService; } public LocalPropertyEditorSupport() { super(); } public void setAsText(String text) throws IllegalArgumentException { Integer idLocal = Integer.parseInt(text); try{ Local local = this.localBoService.getLocalByIdLocal(idLocal); setValue(local); } catch(MyGlobalException mge){ } } }
My Action class is the follow (FormAction) (BTW I got the same results if the bold part below I move it into a constructor)Code:@Table(name = "local") public class Local implements Serializable { private static final long serialVersionUID = 1L; private Integer idLocal; private String estadoLocal; private String nombreLocal; ...
Below the view stateCode:@Component("controlprematriculaaction") public class ControlPreMatriculaAction extends FormAction{ .... @Override protected Object createFormObject(RequestContext context) throws Exception{ logger.info("createFormObject"); this.setValidator(this.controlPreMatriculaValidator); this.setPropertyEditorRegistrar(this.controlPreMatriculaPropertyEditorRegistrar); this.setFormObjectClass(ControlPreMatricula.class); this.setFormObjectName("controlPreMatriculaModel"); this.setFormObjectScope(ScopeType.FLOW); ControlPreMatricula controlPreMatricula = this.controlPreMatriculaBoService.crearControlPreMatricula(); controlPreMatricula.setFechaControlPreMatricula(new Date()); return controlPreMatricula; }
Same result if I use onlyCode:<view-state id="generarcontrolprematricula" view="generarcontrolprematricula" model="controlPreMatriculaModel"> <on-render> <evaluate expression="controlprematriculaaction.setupForm(flowRequestContext)" /> <evaluate expression="controlprematriculaaction.getAllRelationCollection(flowRequestContext)" /> </on-render> <transition on="next" to="controlprematriculacancelado" bind="true" validate="true"/> <transition on="cancel" to="controlprematriculacancelado" bind="false" validate="false"/> </view-state>
The Web Form isCode:<evaluate expression="controlprematriculaaction.setupForm" />
About the date field always I got Wed Jul 06 00:00:00 COT 2011 format when the page is rendered.Code:<form:form modelAttribute="controlPreMatriculaModel"> <table> <tr> <td><spring:message code="localSeleccion" text="No deberia aparecer" /></td> <td> <form:select path="local" id="listalocales" style="width: 300px" items="${listalocales}" itemValue="idLocal" itemLabel="nombreLocal" /> </td> <td><form:errors path="local" class="error" /></td> </tr> ..... <tr> <td><spring:message code="fechaInicioDeseado" /></td> <td> <form:input path="fechaControlPreMatricula" size="45" readonly="readonly" /> </td> <td><form:errors path="fechaControlPreMatricula" class="error" /></td> </tr>
Therefore is not detected the follow
BTW I use this same code for Spring MVC and work fine, I see the expected format when the jsp page is rendered, therefore is not mandatory use <fmt:formatDate tagCode:SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy"); dateFormat.setLenient(false); registry.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
Other problem is when I do the submit event, I got for all my list or select tags or collections the follow error message typeMismatch on local, therefore my LocalPropertyEditorSupport are not working really, I wrote logger lines and always appear in my console/terminal, never I receive an error through there, (BTW even If I include logger lines in the catch scope, never appear when I execute the code, therefore none exception is thrown)
why work for Spring MVC and not for SWF 2.0.x ?
I have no ideas, please give me a hand
Thanks in advanced


Reply With Quote