简体   繁体   English

对话框InputText Primefaces jsf的错误验证

[英]Error Validation of a Dialog InputText Primefaces jsf

I have a DataTable and edit a listing you have to open the Dialog component with the respective values ​​that sends the selected object from the DataTable , but cannot open. 我有一个DataTable并编辑列表,您必须打开具有各个值的Dialog组件,该组件会从DataTable发送选定的对象,但无法打开。 I have noticed that the function is REQUIRED = "true" and also that no error is displayed, the only solution that helped me erase the function is REQUIRED . 我注意到该函数是REQUIRED = "true"并且也没有错误显示,唯一帮助我擦除该函数的解决方案是REQUIRED

How do I to bring up the Dialog component without taking the REQUIRED function. 如何在不使用REQUIRED函数的情况REQUIRED出Dialog组件。 An example of the code: 代码示例:

<p:tab id="tab_listar" title="#{msg.labelListar}">
    <h:form id="form_mostrar_listado">
        <p:dialog id="ModificarLugar" header="Modificar Datos" widgetVar="LugarDialogo2"
                  modal="false" resizable="false" hideEffect="bounce" showEffect="explode">
            <h:panelGrid id="ModificarLugar1" columns="2" cellpadding="5">
                <h:outputText value="#{msg.labelCodigo}"/>
                <h:outputText value="#{BeanLugar.objLugarMod.cod_lugar}"/>
                <h:outputText value="#{msg.labelNombre}"/>
                <p:inputText value="#{BeanLugar.objLugarMod.nombre}" id="nombre_lu_mod"
                             required="true" requiredMessage="#{msg.labelNoVacio}"
                             validatorMessage="#{msg.labelNoValido}"> </p:inputText>
                <h:outputText value="#{msg.labelUbicacion}"/>
                <h:panelGroup>
                    <p:selectOneMenu value="#{BeanLugar.objLugarMod.objPais.cod_pais}"
                                     required="true" id="cod_pais_mod" effect="fade"
                                     requiredMessage="#{msg.labelNoVacio}"
                                     validatorMessage="#{msg.labelNoValido}">
                        <f:selectItem itemLabel="#{msg.labelEligePais}" itemValue=""/>
                        <f:selectItems value="#{Pais.cargarComboPais}"/>
                    </p:selectOneMenu>
                    <h:message showDetail="false" showSummary="true" for="cod_pais_mod"/>
                </h:panelGroup>
                <p:commandButton value="Cancelar" actionListener="#{BeanLugar.doiniciarModLugar()}"
                                 update=":LugarTabView:form_mostrar_listado" icon="ui-icon-triangl-1-w"
                                 immediate="true"> </p:commandButton>

                <p:commandButton id="btn_actualizar" value="#{msg.btnActualizar}"
                                 update=":LugarTabView:form_mostrar_listado"
                                 actionListener="#{BeanLugar.doActualizaLugar()}"> </p:commandButton>
            </h:panelGrid>
        </p:dialog>
        <p:panel id="datListadoLugar">
            <h:outputText value="#{msg.labelListado}"/>
            <h:panelGrid columns="3" cellspacing="10" width="100">

                <p:commandButton value="#{msg.btnNuevo}" update="form_mostrar_listado"
                                 actionListener="#{BeanLugar.doiniciarListadoLugar()}"/>
                <p:commandButton value="#{msg.btnListar}" update="form_mostrar_listado"
                                 actionListener="#{BeanLugar.doListarLugar()}"/>
            </h:panelGrid>
            <h:panelGrid columns="2" rendered="#{BeanLugar.sizeLugar ne '0'}">
                <h:outputText value="#{msg.labelCantidad}"/>
                <h:outputText value="#{BeanLugar.arrLugar.size()}"/>

            </h:panelGrid>
            <h:panelGrid columns="1" rendered="#{BeanLugar.sizeLugar ne '0'}">
                <p:dataTable id="resListadoLugar" value="#{BeanLugar.doListarLugar()}" var="ls"
                             paginator="true" rows="5" paginatorPosition="both" rowsPerPageTemplate="5,10,15">

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.labelLugar}"/>
                        </f:facet>
                        <h:outputText value="#{ls.nombre}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.labelUbicacion}"/>
                        </f:facet>
                        <h:outputText value="#{ls.objPais.nomb_pais}"/>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.labelVer}"/>
                        </f:facet>
                        <p:commandLink title="Ver" action="#{BeanLugar.mostrarLugar(ls)}"
                                       value="Ver" update=":LugarTabView:form_mostrar_listado:DetalleLugar"
                                       oncomplete="LugarDialogo.show()"> </p:commandLink>
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.labelEditar}"/>
                        </f:facet>
                        <p:commandLink title="Editar" action="#{BeanLugar.editarLugar(ls)}"
                                       value="Editar"
                                       update=":LugarTabView:form_mostrar_listado:ModificarLugar"
                                       oncomplete="LugarDialogo2.show()"> </p:commandLink>
                    </p:column>
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.labelEliminar}"/>
                        </f:facet>
                        <p:commandLink title="Eliminar" action="#{BeanLugar.eliminarLugar(ls)}"
                                       value="Eliminar"
                                       update=":LugarTabView:form_mostrar_listado:EliminarLugar"
                                       oncomplete="LugarDialogo3.show()"> </p:commandLink>

                    </p:column>
                </p:dataTable>
            </h:panelGrid>
        </p:panel>
    </h:form>
</p:tab>

You are processing all form so JSF tries yo validate all components with required true. 您正在处理所有表单,因此JSF会尝试使用必需的true来验证所有组件。 You have to tell commandLink what you want to process, for example: 您必须告诉commandLink您要处理的内容,例如:

 <p:commandLink title="Editar" action="#{BeanLugar.editarLugar(ls)}"
                                   value="Editar"
             update=":LugarTabView:form_mostrar_listado:ModificarLugar"
                                    oncomplete="LugarDialogo2.show()"
   process="resListadoLugar"> // or the path of the component you want to process
  </p:commandLink>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM