包含在facelets模板客户端中的<f:viewaction>不起作用

时间:2015-09-29 06:40:22

标签: facelets jsf-2.2 viewaction

只是一个问题....不知道我是否做得对,或者这不符合规格。我制作了一个简单的facelets主模板,如下所示:

的template.xhtml

    <html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

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

        <h:head>    

....  here the rest of template with other <ui:insert>

客户端很简单,并使用模板:

main.xhtml

<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                template="./WEB-INF/template/template.xhtml">

    <ui:define name="metadata">        
        <ui:include src="./WEB-INF/template/securityCheck.xhtml" />
    </ui:define>

... here goes the rest with other <ui:define> and <ui:include> ....

securityCheck.xhtml 中,简单的f:viewAction如下:

securityCheck.xhtml

<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                xmlns:f="http://xmlns.jcp.org/jsf/core">

    <f:metadata>
        <f:viewAction action="#{loginController.doLoginCheck()}" />
    </f:metadata>
</ui:composition>

好吧,在这个cas中,f:viewAction没有被调用,相反,如果我直接将代码扩展到元数据部分,如下所示:

main.xhtml

<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                template="./WEB-INF/template/template.xhtml">

    <ui:define name="metadata">        
        <f:metadata>
            <f:viewAction action="#{loginController.doLoginCheck()}" />
        </f:metadata>
    </ui:define>

... here goes the rest with other <ui:define> and <ui:include> ....

它就像一个魅力(如预期的那样)。为什么包含元数据部分到模板客户端不起作用?如果有一个正确的方法,我怎么能添加其他f:viewAction调用后?像这样:

otherpage.xhtml

<ui:composition xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
                xmlns:f="http://xmlns.jcp.org/jsf/core"
                xmlns:h="http://xmlns.jcp.org/jsf/html"
                template="./WEB-INF/template/template.xhtml">

    <ui:define name="metadata"> 
        <ui:include src="./WEB-INF/template/securityCheck.xhtml" />
        <f:metadata>
            <f:viewAction action="#{myBean.doSomething()}" />
        </f:metadata>
    </ui:define>

... here goes the rest with other <ui:define> and <ui:include> ....

如果这是正确的,是否以此特定顺序进行了调用?

我正在使用带有Glassfish 4.1和Mojarra 2.2.12 impl的JavaEE 7 / JSF 2.2。

谢谢。

0 个答案:

没有答案