JSF,Spring和PreRenderViewEvent [英] JSF, Spring, and the PreRenderViewEvent

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

问题描述

我正在尝试将Spring 3集成到JSF 2项目中.我在faces-config.xml中注册了 SpringBeanFacesELResolver,并向其中添加了两个侦听器web.xml:

I'm trying to integrate Spring 3 into a JSF 2 project. I registered the SpringBeanFacesELResolver in the faces-config.xml and I added two listeners to the web.xml:

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

大多数视图和支持bean都在起作用,但不幸的是,javax.faces.event.PreRenderViewEvent不再起作用.在渲染视图之前,我一直在使用此事件在backing-bean中调用方法:

Most views and backing-beans are just working, but unfortunately, the javax.faces.event.PreRenderViewEvent ceased to function. I have been using this event to call a method in the backing-bean before the view is rendered:

<ui:define name="metadata">
    <f:event type="javax.faces.event.PreRenderViewEvent"
        listener="#{locationBean.preRenderView}" />
</ui:define>

在使用Spring 3创建bean的地方,不再调用preRenderView方法.我非常感谢我做错了什么或想念什么的任何提示!

With Spring 3 in place for bean creation, the preRenderView method is no longer called. I'd greatly appreciate any hint on what I might be doing wrong or missing!

更新:

在同一视图中,我试图像这样将参数绑定到backing-bean的属性:

In the same view, I'm trying to bind a parameter to a property of the backing-bean like this:

<ui:define name="metadata">
    <f:metadata>
        <f:viewParam name="id" value="#{locationBean.id}" label="id" />
    </f:metadata>
</ui:define>

这过去也可以使用纯" JSF 2进行,但是不能使用Spring进行任何操作.

This also used to work using "pure" JSF 2 but fails to do anything using Spring.

推荐答案

这与Spring无关,但据我所知f:metadata标签必须包含在模板客户端中,并直接插入到f:view中.可以在 JSFAtWork .链接是德语,但我希望代码示例清楚.

This is not really spring related but as far as I know the f:metadata tag has to be contained inside the template client and be inserted directly inside f:view. An example can be found at JSFAtWork. The link is in german but I hope the code examples are clear.

您的代码必须看起来像这样

Your code would have to look like this

<ui:define name="metadata">
    <f:metadate>
        <f:event type="javax.faces.event.PreRenderViewEvent"
            listener="#{locationBean.preRenderView}" />
    </f:metadate>
</ui:define>

使用以下模板

<f:view>
    <ui:insert name="metadata"/>
    ...
</f:view>

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

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