组件SelectOneMenu primefaces不适用于Dialog组件

时间:2017-05-01 22:34:21

标签: jsf primefaces jsf-2.2

PrimeFaces的p:selectOneMenup:dialog内不起作用。他的外表没有配置。通过删除组件,其他组件正常工作。

我在对话框中已经appendToBody="true",但仍然无效。如果某人已经经历过这种情况或对此行为有所了解,请留下您的评论或回复。

调用对话框的按钮

<button id="btnNovoContatoID" 
    class="btn btn-flat btn-info"
    onclick="PF('dlgNovoContato').show(); return false;"
    jsf:update="modalNovoContato"
    >Novo Contato
</button>

包含对话

<ui:define name="popups">
    <ui:include src="teste.xhtml"/>
</ui:define>

填写表格

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"  
                xmlns:p="http://primefaces.org/ui"
                xmlns:o="http://omnifaces.org/ui"
                xmlns:jsf="http://xmlns.jcp.org/jsf"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:sgr="http://www.sgr.com.br/jsf"  
                template="/WEB-INF/facelets/templates/layout.xhtml">

    <ui:param name="form_id" value="formCadPessoa"/>
    <ui:param name="titlePage" value="Pessoa"/>
    <ui:param name="subTitlePage" value="Cadastrado de Pessoas"/>

    <f:metadata>
        <f:viewAction action="#{pessoaBean.inicializarFormParaEdicao(param.pessoaId)}"/>
    </f:metadata>

    <ui:define name="panelCadastro">

        <p:panelGrid columns="2" layout="grid" columnClasses="ui-grid-col-2, ui-grid-col-7" styleClass="ui-panelgrid-blank">
            <p:outputLabel value="Nome:"/>
            <p:inputText id="inptNome" value="#{pessoaBean.pessoa.nome}"/>
        </p:panelGrid>

        <p:panelGrid columns="2" layout="grid" columnClasses="ui-grid-col-2, ui-grid-col-3" styleClass="ui-panelgrid-blank">
            <p:outputLabel value="Tipo Pessoa:"/>
            <p:selectOneMenu id="iptTipPessoa" value="#{pessoaBean.pessoa.tipoPessoa}" converter="tipoPessoaConverter" >
                <p:ajax event="change" update="lblCpf"/>
                <f:selectItems value="#{pessoaBean.tiposPessoa}"/>
            </p:selectOneMenu>

            <p:outputLabel id="lblCpf" value="#{pessoaBean.pessoa.tipoPessoa eq 'FISICA' ? 'CPF' : 'CNPJ'}:"/>
            <p:inputText value="#{pessoaBean.pessoa.cpfCnpj}" maxlength="14"/>

            <p:outputLabel value="Nascimento:"/>
            <p:calendar value="#{pessoaBean.pessoa.dataNascimento}" pattern="dd/MM/yyyy" />
        </p:panelGrid>

        <p:panelGrid columns="1" layout="grid" columnClasses="ui-grid-col-12" styleClass="ui-panelgrid-blank">
            <div class="box-title pull-right">
                <button id="btnNovoContatoID" 
                        class="btn btn-flat btn-info"
                        onclick="PF('dlgNovoContato').show(); return false;"
                        jsf:update="modalNovoContato"
                        >Novo Contato
                </button>
            </div>
        </p:panelGrid>

        <p:dataTable id="dtContatos" var="obj" value="#{pessoaBean.pessoa.contatos}">

            <f:facet name="header">
                Contatos Cadastrados
            </f:facet>

            <p:column headerText="Tipo" width="20%">
                <h:outputText value="#{obj.tipoContato}"/>
            </p:column>
            <p:column headerText="Descrição" width="80%">
                <h:outputText value="#{obj.descricao}"/>
            </p:column>
        </p:dataTable>
    </ui:define>

    <ui:define name="footerBoxButton">
        <button id="btnSalvarID"
                type="submit" 
                jsf:update="messages,formCadPessoa"
                jsf:process="@form"
                class="btn btn-flat btn-success"
                jsf:action="#{pessoaBean.salvar}">Salvar
        </button>

        <p:spacer width="10"/>

        <a href="javascript:history.back()" class="btn  btn-default">Voltar</a>
    </ui:define>

    <ui:define name="popups">
        <ui:include src="teste.xhtml"/>
    </ui:define>
</ui:composition>

对话框页面

<p:dialog xmlns="http://www.w3.org/1999/xhtml"
    xmlns:p="http://primefaces.org/ui"
    xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:jsf="http://xmlns.jcp.org/jsf"
    xmlns:sgr="http://www.sgr.com.br/jsf"   
    id="modalNovoContato"
    header="Novo Contato" 
    widgetVar="dlgNovoContato" 
    minHeight="200"
    width="650"
    resizable="false" 
    closeOnEscape="true">

    <p:panelGrid columns="2" layout="grid" columnClasses="ui-grid-col-3, ui-grid-col-9" styleClass="ui-panelgrid-blank">
        <h:outputLabel value="Tipo Contato:" />

        <p:selectOneMenu value="#{pessoaBean.contato.tipoContato}" converter="tipoContatoConverter" >
            <f:selectItems value="#{pessoaBean.tiposContato}"/>
        </p:selectOneMenu>

        <h:outputLabel value="Descrição:"/>
        <p:inputText label="inputDescricao" style="width: 300px">
            <sgr:upperCase/>
        </p:inputText>
    </p:panelGrid>

    <f:facet name="footer">
        <button id="btnSalvarContatoID" 
            type="submit" 
            jsf:update="messages"
            jsf:process="@form"
            jsf:action="#{pessoaBean.salvar}"
            class="btn btn-flat btn-success">Adicionar
        </button>
    </f:facet>
</p:dialog>

错误的对话框图片

enter image description here

0 个答案:

没有答案