Menu

Dependency Injection into a <converter>

Users
2005-04-12
2013-04-08
  • Mike Kienenberger

    I have a Spring bean that I want to inject into a converter.
    I currently inject this bean into my JSF managed beans like this:

    </managed-bean>
    <managed-bean-name>viewLocationCategoriesPage</managed-bean-name>     
    <managed-bean-class>com.gvea.eng_work_mgmt.page.ViewLocationCategories</managed-bean-class>     <managed-bean-scope>request</managed-bean-scope>
            <managed-property>            <property-name>activityTypeDataStore</property-name>
                <value>#{activityTypeDataStore}</value>
            </managed-property>
    </managed-bean>

    However, I've been unable to determine how to inject it into a converter.

    My only thoughts are to configure the converter programmically rather than using faces-config.xml.

    -Mike

     
    • Thomas Jachmann

      Thomas Jachmann - 2005-04-12

      Hi Mike!

      I haven't tried this, so I can only answer with a suggestion:

      The converter tag can have a nested tag called property. This can be used to set JavaBeans properties on the converter instance. Have you tried this? I don't know if you can use the # notation to reference other beans, though. If not, you could just use a string property of the converter, say activityTypeDataStoreBeanName, set it to the bean's name and then let the converter retrieve the bean programatically. Bit of a hack, but hey...

      HTH,
      Thomas

       
    • Mike Kienenberger

      Thanks for the feedback.

      I looked into using <property>, but from what little info I could find (couple paragraphs in JSF by Bergsten, nothing in JSF in Action or Mastering JSF), the <property> and <attribute> values are only used to provide interaction to developer tools hosting the components.

      And after trying to use them anyway, as near as I can tell, property for converter isn't supported for converter yet in myfaces:

      $Log: Property.java,v $ Revision 1.1 2005/03/04 00:28:45 mmarinschek Changes in configuration due to missing Attribute/Property classes for the converter; not building in the functionality yet except for part of the converter properties

      Perhaps this is too soon.   I guess I'll do it the wrong way for now and figure out how to fix it at some point in the future.

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.