开发者

JSF, Spring, and the PreRenderViewEvent

I'm trying to integrate Spring 3 into a JSF 2 pro开发者_StackOverflowject. 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>

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>

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!

Update:

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>

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


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>

With the following template

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜