jsf - 使用primefaces对未处理的输入进行验证失败

时间:2014-03-29 19:31:52

标签: java jsf jsf-2 primefaces

我正在使用primefaces,在提交表单时,我对未处理的输入进行验证失败: -

<h:form id="result">
<p:outputPanel>
<m:inputProperty property="#{prop}"></m:inputProperty>
</p:outputPanel>
<p:inputText value="#{helper.subFormName}" required="true" styleClass="noprocess"
requiredMessage="#{tags.requiredMessage}" />
<p:commandButton value="#{msg.register}" action="#{registerBean.register}"
process="@(form:not(.noprocess))"></p:commandButton>
</h:form>

表单未提交,因为类noprocess的空必需输入

那有什么问题?这是过程表达吗?或者什么?

1 个答案:

答案 0 :(得分:1)

在“form”和“:not”元素之间添加空格。

@(form :not(.noprocess)) 

我试试。它工作正常。如果单击提交,则只验证input2和input3。

<?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://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui">
<h:head>
    <title>Primefaces Selectors</title>
</h:head>
<h:body>
    <h:form>
        <p:messages autoUpdate="true" />
        <h:panelGrid columns="2">
            <p:outputLabel value="Input 1:" for="input1"/>
            <p:inputText id="input1" value="" required="true" styleClass="noprocess"/>

            <p:outputLabel value="Input 2:" for="input2"/>
            <p:inputText id="input2" value="" required="true"/>

            <p:outputLabel value="Input 3:" for="input3"/>
            <p:inputText id="input3" value="" required="true"/>
        </h:panelGrid>
        <p:commandButton value="Submit" process="@(form :not(.noprocess))" />
    </h:form>
</h:body>
</html>