Menu

Spring BeanFactory via useBeanFactory

Users
2006-11-29
2013-04-08
  • Bhushan Bhangale

    I have successfully used jsf-spring with jsf on jboss. The only problem is this -

    I want to define my spring bean config like this. Seggregating the beans in different files.

    <beans>
        <bean id="com.lastminute.judith.dashboard" class="org.springframework.context.support.ClassPathXmlApplicationContext">
            <constructor-arg>
                <list>
                    <value>datasource-context.xml</value>       
                    <value>dao-context.xml</value>       
                    <value>user-context.xml</value>       
                </list>
            </constructor-arg>
    </bean>
    </beans>

    I define this faces config trying to access judithSessionManager defined in user-context.xml above. But faces doesn't find the bean. I know some where the creation of spring BeanFactory should be via beanFactoryLocator.useBeanFactory("com.lastminute.judith.dashboard"). But where do I plugin this? Please help.

    <faces-config>
        <managed-bean>
            <managed-bean-name>userAction</managed-bean-name>
            <managed-bean-class>com.lastminute.judith.dashboard.dao.user.UserAction</managed-bean-class>
            <managed-bean-scope>request</managed-bean-scope>
            <managed-property>
                <property-name>judithSessionManager</property-name>
                <value>#{judithSessionManager}</value>
            </managed-property>
        </managed-bean>
    </faces-config>

     
    • Bhushan Bhangale

      I found the solution after going through the jsf-spring java code.

      One need to define these two context params
         
          <context-param>
              <param-name>faces.spring.context.locatorFactorySelector</param-name>
              <param-value>/WEB-INF/judith-dashboard-context.xml</param-value>
          </context-param>

          <context-param>
              <param-name>faces.spring.context.parentContextKey</param-name>
              <param-value>com.lastminute.judith.dashboard</param-value>
          </context-param>

      And remove this listener

      <listener>
          <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>

       

Log in to post a comment.