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

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

问题描述

问题描述:我注入的 Spring bean 定义为 JSF 支持 bean 的托管属性没有被实例化.当我检索托管 Bean 时,它总是为空.

我一整天都在与这个问题作斗争,似乎 JSF Managed Bean 只是不会从 Spring 中读取 applicationContext.我可以通过在支持 bean 中使用 FacesContext 手动拉出 bean 并找到 bean,但是当我尝试通过 FacesConfig 注入它时,它总是为空.我在下面包含了我如何集成它的步骤.有什么建议?

配置

冰面 1.85

JSF 1.2(通过冰面 servlet)

春季 3.0

Websphere 7.5(我认为是 eclipse 3.5)

Web.xml 配置更改

Spring 上下文加载器监听器

 <display-name>SpringListener</display-name><图标><small-icon>small.gif</small-icon><大图标>大.gif</大图标></图标><listener-class>org.springframework.web.context.ContextLoaderListener</listener-class></监听器>

上下文配置

<param-name>contextConfigLocation</param-name><参数值>/WEB-INF/SpringConfig/SpringHelloWorld.xml</参数值></context-param>

FacesContext 变化

变量解析器 - 又名胶水

org.springframework.web.jsf.DelegatingVariableResolver

托管 Bean

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

Spring.xml 配置

提前致谢

解决方案

首先,我认为这是您的问题,即 DelegatingVariableResolver 在 1.1 之后的所有 JSF 版本中均已弃用,而您使用的是 1.2,因此请使用以下配置.

>

<应用程序><el解析器>org.springframework.web.jsf.el.SpringBeanFacesELResolver</el-resolver></应用程序>

希望有帮助.

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 Beans的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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