Spring bean注入JSF Managed Bean [英] Spring beans injected into JSF Managed Beans

查看:173
本文介绍了Spring bean注入JSF Managed Bean的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题描述:我注入的Spring bean定义为一个JSF支持bean的Managed-Property没有被实例化。当我检索Managed-Bean时,它总是为null。



我一直在与这一整天战斗,似乎JSF Managed Bean只是不会从Spring读取applicationContext。我可以通过使用FacesContext在支持bean中手动拉出bean,它找到了bean,但是当我尝试通过FacesConfig注入它总是出来null。我包括我的步骤如何我如何集成它。有什么建议么?



配置



Icefaces 1.85



JSF 1.2 (通过冰面servlet)



Spring 3.0



Websphere 7.5(这是eclipse 3.5) p>

Web.xml配置更改



Spring Context Loader侦听器



 < listener> 
< display-name> SpringListener< / display-name>
< icon>
< small-icon> small.gif< / small-icon>
< large-icon> large.gif< / large-icon>
< / icon>
< listener-class> org.springframework.web.context.ContextLoaderListener< / listener-class>
< / listener>



上下文配置



 < context-param> 
< param-name> contextConfigLocation< / param-name>
< param-value>
/WEB-INF/SpringConfig/SpringHelloWorld.xml
< / param-value>
< / context-param>



FacesContext变更



变量解析器The Glue



< application>< variable-resolver> org.springframework.web.jsf.DelegatingVariableResolver< / variable-resolver>< / application>



托管Bean



 < managed-bean> 
< managed-bean-name> testData< / managed-bean-name>
< managed-bean-class> src.test.TestData< / managed-bean-class>
< managed-bean-scope> session< / managed-bean-scope>
< managed-property>
< property-name> spring3HelloWorldBean< / property-name>
< value>#{spring3HelloWorldBean}< / value>
< / managed-property>
< / managed-bean>



Spring.xml配置



 < bean id =spring3HelloWorldBeanclass =src.test.Spring3HelloWorld/> 





>

解决方案

首先,我认为这个你的问题,DelegatingVariableResolver在1.1之后的所有JSF版本都被弃用,你使用1.2,

 < application> 
< el-resolver>
org.springframework.web.jsf.el.SpringBeanFacesELResolver
< / el-resolver>
< / application>

希望它有帮助。


Problem Description: My injected Spring bean defined as a Managed-Property to a JSF backing bean is not being instantiated. Its always coming up null when I retreive the Managed-Bean.

I have been fighting with this all day and it seems that JSF Managed Bean just won't read out of the applicationContext from Spring. I can manually pull out the bean by using the FacesContext in a backing bean and it finds the bean but when I try and inject it through the FacesConfig it always comes out null. I included my steps below how I integrated it. Any suggestions?

Configuration

Icefaces 1.85

JSF 1.2 (through ice faces servlet)

Spring 3.0

Websphere 7.5 ( Which is eclipse 3.5 I think )

Web.xml Configuration Changes

Spring Context Loader Listener

    <listener>
    <display-name>SpringListener</display-name>
    <icon>
        <small-icon>small.gif</small-icon>
        <large-icon>large.gif</large-icon>
    </icon>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

Context Config

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
        /WEB-INF/SpringConfig/SpringHelloWorld.xml
    </param-value> 
</context-param>

FacesContext Changes

Variable Resolver - AKA The Glue

<application><variable-resolver>org.springframework.web.jsf.DelegatingVariableResolver</variable-resolver></application>

Managed Bean

   <managed-bean>
    <managed-bean-name>testData</managed-bean-name>
    <managed-bean-class>src.test.TestData</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
    <managed-property>
        <property-name>spring3HelloWorldBean</property-name>
        <value>#{spring3HelloWorldBean}</value>
    </managed-property>
</managed-bean>

Spring.xml Config

<bean id="spring3HelloWorldBean" class="src.test.Spring3HelloWorld" />

Thanks in advance

解决方案

First of all and I think this your problem that DelegatingVariableResolver is deprecated in all JSF version after 1.1 and you are using 1.2 so please use this following configuration.

<application> 
<el-resolver> 
org.springframework.web.jsf.el.SpringBeanFacesELResolver 
</el-resolver> 
</application>

Hope it helps.

这篇关于Spring bean注入JSF Managed Bean的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆