Announcement Announcement Module
No announcement yet.
Problem With Custom Property Editor Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem With Custom Property Editor

    I'm new comer on swf. I try to use custom property editor but not success yet.
    I have a entity BorrowingBook with two field have a Date property. I try to use propertyEditorRegistrar in my flow config look like this :

     <bean id="borrowBookAction" class="org.springframework.webflow.action.FormAction">
            <property name="formObjectClass" value="org.kris.entity.BorrowingRecord"/>
            <property name="propertyEditorRegistrar" value="org.test.util.PropertyEditors"/>
    And this is my PropertyEditors implementation :
    public class PropertyEditors implements PropertyEditorRegistrar{
        public void registerCustomEditors(PropertyEditorRegistry registry) {
            SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy-mm-dd");
            registry.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
    This class entity :
    public class BorrowingRecord implements Serializable {
        @GeneratedValue(strategy = GenerationType.AUTO)
        private Long id;
        private String isbn;
        private Date borrowDate;
        private Date returnDate;
        private String reader;
    but if i try to run this code i getting error look like this :
    Caused by: java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.springframework.beans.PropertyEditorRegistrar] for property 'propertyEditorRegistrar': no matching editors or conversion strategy found
    I don't know how to use it with proper value with my entity class property. How to use property editor for spesific value ?
    Is there another way to use it ?

    Thanks lot before...
    Last edited by nyuby; Jan 31st, 2010, 08:06 AM.

  • #2
    i'm sory,, this is my little mistake,
    Problem solve....


    • #3
      I am having difficulty with custom property editors using webflow. I followed the steps included in the documentation as well as numerous forms to setup the custom property editors in webflow. However, I was not successful in implementing the custom editors.
      • My requirement is when user enters a value into the amount attribute the custom property editor should strip off any $ or coma signs before validation
      • The custom attribute is of type "int" primitive data type

      The followins are my stup steps:

      1. I have registered the custom property editor using PropertyEditorRegistrar:

      package com.ui.protools.web.customEditors;
      import org.springframework.beans.PropertyEditorRegistrar;
      import org.springframework.beans.PropertyEditorRegistry;
      public class AgencyLoginPropertyEditorRegistrar implements PropertyEditorRegistrar {
      	 * method to register custom property editors.
      	public void registerCustomEditors(PropertyEditorRegistry registry) {
              registry.registerCustomEditor(int.class, new CustomIntEditor(Integer.class, true));
      2. I have injected the propertyEditorRegistrar into my FormAction:

      <bean id="agencySearchDetailsAction" scope="prototype"
      		<property name="propertyEditorRegistrar" ref="agencyLoginPropertyEditorRegistrar" />
      		<property name="formObjectClass" value="com.ui.protools.domain.Bonds"/>
      		<property name="formObjectName" value="bondData"/>
      		<property name="formObjectScope" value="FLOW"/>
      3. I am calling setupForm method in my flow:

      <view-state id="bondDetails" view="agency/bond_details"
      				expression="agencySearchDetailsAction.processBonds(flowRequestContext)" />
      				expression="agencySearchDetailsAction.setupForm(flowRequestContext)" />
      		<transition on="save" to="bondFinish">
      				expression="agencySearchDetailsAction.bind(flowRequestContext)" />
      				expression="agencySearchDetailsAction.saveBondData(flowRequestContext)" />
      		<transition on="back" to="bondFinish" validate="false" />
      When I run the application in the debug mode, the custom editor is being registered and the formObject is getting bound.

      However, during the form submission, the custom editor setAsText() and getAsText() methods are not being called to strip off the additional characters within the amount filed before it reaches the validation class.

      Hence the amount attribute does not pass the validation and therefore, asks the user to re-enter the amount value.

      Just for your information, the validator class is build based on the webflow 2.0.7 documentation.
      create a class whose name has the pattern ${model}Validator, where ${model} is the capitialized form of the model expression, such as booking. Then define a public method with the name validate${state}, where ${state} is the id of your view-state, such as enterBookingDetails. The class should then be deployed as a Spring bean.
      What am I doing wrong? Why isn't the custom editor being invoked before the validator class? Any help is appreciated.