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

  • Complex PropertyEditor registration

    Hi all !

    I'm trying to add a custom property editor to my application:

    Code:
      <bean id="propertyEditorRegistry" class="org.springframework.richclient.application.support.DefaultPropertyEditorRegistry">
        <property name="propertyEditors">
          <list>   
            <props>
              <prop key="objectClass">BusinessContext</prop>
              <prop key="propertyEditorClass">BusinessContextEditor</prop>
            </props>
          </list>
        </property>
      </bean>
    Ok, it works fine. Now I'd like to inject the "businessContextManager" bean in my BusinessContextEditor :
    Code:
      <bean id="businessContextManager" class="BusinessContextManagerImpl">
        <property name="businessContextDao"><ref local="businessContextDao"/></property>
        ...
       </bean>
    Code:
      public class BusinessContextEditor&#40;&#41; extends AbstractCustomPropertyEditor
      &#123;
        ...
    
        public void setBusinessContextManager&#40;BusinessContextManager businessContextManager&#41; &#123;
        ...
        &#125;
    
        ...
      &#125;
    The problem is that as I register my editor in the DefaultPropertyEditorRegistry, my editor is not yet instantiated when my configuration file is parsed. So what should I do ?

    My first thought was that maybe my BusinessContextEditor could implement the ApplicationContextAware interface, and once the PropertyEditorRegistry would instantiate my editor bean, it would inject the application context into it.

    Another way could be to be able to inject an instance of the PropertyEditor in the registry directly (not a class) ?
    Code:
      public interface PropertyEditorRegistry &#123;
      ...
      public void setPropertyEditor&#40;Class typeClass, java.beans.PropertyEditor propertyEditorInstance&#41;;
      
      ...
      &#125;
    What do you think ? Did I miss something about the PropertyEditorRegistry ?

    Dominique

  • #2
    I've checked out the code submitted by Oliver this morning. I still have to take into account all those changes in my code, but from what I see, it seems to solve my problem thanks to the "BinderSelectionStrategy".

    Thanks Oliver !!!!
    Thanks RCP team !!!

    Comment

    Working...
    X