当存在渲染属性时,未调用primefaces commandButton动作

时间:2015-12-01 12:37:06

标签: jsf jsf-2 primefaces

我正在使用primefaces commandButton创建一个jsf页面,此按钮将基于为页面传递的viewParam进行渲染。如果viewParam为true,则将显示commandButton,否则不显示。我正在使用action属性从这个commandButton调用一个方法。我的方法不是调用,页面中没有显示错误。如果我调用没有'rendering'属性的方法,它可以正常工作。

使用具有请求范围和以下配置的CDI bean:primefaces 5.0,JSF 2.2,Glassfish Server 4.1。 我的代码:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui">
    <h:head>
        <title>Facelet Title</title>
     </h:head>
    <h:body>
        <ui:composition xmlns="http://www.w3.org/1999/xhtml"
                        xmlns:ui="http://java.sun.com/jsf/facelets"
                        xmlns:f="http://java.sun.com/jsf/core"
                        template="TopLayout.xhtml">
            <ui:define name="metaData">
            <f:metadata>
                <f:viewParam name="showButton" value="#{chartView.showButton}" />
            </f:metadata>
        </ui:define>
            <ui:define name="content">
                <p:messages autoUpdate="true"/>
                <h:form>
                    <p:commandButton value="Submit" action="printInvoice" rendered="#{chartView.showButton}"
                                     ajax="false"/>
                </h:form>
            </ui:define>
        </ui:composition>
    </h:body>
</html>

0 个答案:

没有答案
相关问题