Announcement Announcement Module
Collapse
No announcement yet.
AbstractFormattingConverter Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AbstractFormattingConverter

    Hello springmates,
    please be so kind and help me. I have an entity class with an Character attribute. This attribute cannot be displayed in a form, the No converter registered to convert from sourceClass 'class java.lang.String' to target class 'class java.lang.Character' exeption is thrown.

    1)Shouldnt it be the opposite way? My conveter class looks like this.


    public class CharacterToString extends AbstractFormattingConverter {

    private final boolean allowEmpty;

    protected CharacterToString(FormatterFactory formatterFactory, boolean allowEmpty) {
    super(formatterFactory);
    this.allowEmpty = allowEmpty;
    }

    public CharacterToString(){
    this(new SimpleFormatterFactory(),true);
    }



    public Class[] getSourceClasses() {
    return new Class[] {Character.class};
    }

    public Class[] getTargetClasses() {
    return new Class[] {String.class};
    }



    @Override
    protected Object doConvert(Object source, Class targetClass, ConversionContext context) throws Exception {
    return (!allowEmpty || source!=null) ? source.toString() : null;
    }
    }

    2) Is the declaration in rich-client-app.xml right?

    <bean id="conversionService" class="org.springframework.richclient.application. DefaultConversionServiceFactoryBean" />
    <bean class="org.springframework.beans.factory.config.Me thodInvokingFactoryBean" >
    <property name="targetObject" ref="conversionService" />
    <property name="targetMethod" value="addConverters" />
    <property name="arguments">
    <list>
    <list>
    <bean class="model.CharacterToString" />
    </list>

    </list>
    </property>
    </bean>

    3)Am I at least on the right way to solve my problem or is this exeption matter of something else eg. binding?

    If anyone have ever solved similar problem please help.

    Thank you all, marekto2
Working...
X