Results 1 to 3 of 3

Thread: SWF 2.0 dont recognize my PropertyEditorRegistrar

  1. #1
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Question SWF 2.0 dont recognize my PropertyEditorRegistrar

    Dear Members

    I am trying to reuse my PropertyEditorRegistrar and PropertyEditorSupport used with Spring MVC for SWF 2.0.x

    Below all my code

    Code:
    @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 for example a PropertyEditorSupport has the follow structure

    Code:
    @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){
    		}
    	}
    	
    }
    Where such class is


    Code:
    @Table(name = "local")
    public class Local implements Serializable {
    
    	private static final long serialVersionUID = 1L;
    
    	private Integer idLocal;
    
    	private String estadoLocal;
    	
    	private String nombreLocal;
    ...
    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:
    @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;
    }
    Below the view state

    Code:
    <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>
    Same result if I use only
    Code:
    <evaluate expression="controlprematriculaaction.setupForm" />
    The Web Form is

    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>
    About the date field always I got Wed Jul 06 00:00:00 COT 2011 format when the page is rendered.

    Therefore is not detected the follow
    Code:
    SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
    dateFormat.setLenient(false);		
    registry.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, false));
    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 tag

    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
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,625

    Default

    The problem here is you are mixing and old and new approach... Spring Web Flow uses Converters and Formatters (as Spring MVC 3 does) and not property editors anymore to do conversion. So instead of a PropertyEditorRegistrar you need a ConversionService to configure converts (I suggest the binding and type conversion chapter in the spring web flow reference guide).
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Aug 2006
    Location
    Arequipa-Peru / South America
    Posts
    2,796

    Default

    Hello Marten

    Thanks a lot for the guidance.

    I have already resolved this, I should write a tutorial on my Blog

    is really interesting how these new features does the things easier and reduce good amount of code

    Thank you
    - Manuel Jordan

    Kill Your Pride, Share Your Knowledge With All
    The Fear Of The LORD Is The Beginning Of Knowledge, But Fools Despise Wisdom And Discipline. Proverbs 1:7

    Blog


    Technical Reviewer of Apress

    • Pro SpringSource dm Server
    • Spring Enterprise Recipes: A Problem-Solution Approach
    • Spring Recipes: A Problem-Solution Approach, 2nd Edition
    • Pro Spring Integration
    • Pro Spring Batch
    • Pro Spring 3
    • Pro Spring MVC: With Web Flow
    • Pro Spring Security

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •