单击rowEditor时,如何避免字段验证?

时间:2014-04-28 12:16:41

标签: jsf primefaces

我有一个数据表元素,我使用rowEditor。此外,还可以添加一个新记录,该记录在表的页脚中实现为inputFields。所有元素都经过验证。问题是,当用户点击rowEditor时,验证会抱怨没有设置新记录的值。

如何在单击rowEditor时避免验证新记录字段?

我和proccess& amp;立即参加ajax活动,但我无法弄清楚这一点。这是可能的,如果可以,怎么样?我很感谢你的帮助。

<p:dataTable var="contact"
    value="#{data.activeCustomer.contacts.toArray()}"
    id="contactsTable"
    emptyMessage="#{ivy.cms.co('/Translations/Administration/noRecordsFoundSearch')}"
    editable="true">

    <p:ajax event="rowEdit" listener="#{logic.onEdit(contact)}" />
    <p:ajax event="rowEditCancel" listener="#{logic.onCancel}" />

    <f:facet name="header">  
                            #{ivy.cms.co('/Translations/Administration/Contacts/labelContacts')}
                        </f:facet>

    <p:column
        headerText="#{ivy.cms.co('/Translations/Administration/Contacts/prename')}">
        <p:cellEditor>
            <f:facet name="output">
                <h:outputText value="#{contact.prename}" />
            </f:facet>
            <f:facet name="input">
                <p:inputText required="true"
                    requiredMessage="#{ivy.cms.co('/Translations/CustomerAdministration/Validation/enterPrename')}"
                    value="#{contact.prename}"></p:inputText>
            </f:facet>
        </p:cellEditor>
        <f:facet name="footer">
            <p:inputText required="true"
                requiredMessage="#{ivy.cms.co('/Translations/CustomerAdministration/Validation/enterPrename')}"
                value="#{data.contactPrename}" />
        </f:facet>
    </p:column>

    <p:column
        headerText="#{ivy.cms.co('/Translations/Administration/Contacts/surname')}">
        <p:cellEditor>
            <f:facet name="output">
                <h:outputText value="#{contact.surname}" />
            </f:facet>
            <f:facet name="input">
                <p:inputText required="true"
                    requiredMessage="#{ivy.cms.co('/Translations/CustomerAdministration/Validation/enterSurname')}"
                    value="#{contact.surname}"></p:inputText>
            </f:facet>
        </p:cellEditor>
        <f:facet name="footer">
            <p:inputText required="true"
                requiredMessage="#{ivy.cms.co('/Translations/CustomerAdministration/Validation/enterSurname')}"
                value="#{data.contactSurname}" />
        </f:facet>
    </p:column>

    <p:column
        headerText="#{ivy.cms.co('/Translations/Administration/Contacts/phone')}">
        <p:cellEditor>
            <f:facet name="output">
                <h:outputText value="#{contact.phone}" />
            </f:facet>
            <f:facet name="input">
                <p:inputText value="#{contact.phone}"
                    requiredMessage="#{ivy.cms.co('/Translations/CustomerAdministration/Validation/enterPhone')}"
                    required="true"></p:inputText>
            </f:facet>
        </p:cellEditor>
        <f:facet name="footer">
            <p:inputText
                requiredMessage="#{ivy.cms.co('/Translations/CustomerAdministration/Validation/enterPhone')}"
                required="true" value="#{data.contactPhone}" />
        </f:facet>
    </p:column>

    <p:column
        headerText="#{ivy.cms.co('/Translations/Administration/Contacts/email')}">
        <p:cellEditor>
            <f:facet name="output">
                <h:outputText value="#{contact.email}" />
            </f:facet>
            <f:facet name="input">
                <p:inputText value="#{contact.email}" required="true"
                    requiredMessage="#{ivy.cms.co('/Translations/CustomerAdministration/Validation/enterEmail')}">
                    <f:validator validatorId="EmailValidator" />
                </p:inputText>
            </f:facet>
        </p:cellEditor>
        <f:facet name="footer">
            <p:inputText required="true"
                requiredMessage="#{ivy.cms.co('/Translations/CustomerAdministration/Validation/enterEmail')}"
                value="#{data.contactEmail}">
                <f:validator validatorId="EmailValidator" />
            </p:inputText>
        </f:facet>
    </p:column>

    <p:column style="width: 6%"
        headerText="#{ivy.cms.co('/Translations/CustomerAdministration/actionsColumnTitle')}">
        <p:rowEditor />

        <p:commandLink styleClass="ui-icon ui-icon-trash"
            actionListener="#{logic.deleteContact(contact)}"
            icon="ui-icon-trash" update=":#{p:component('contactForm')}"
            immediate="true" />

        <f:facet name="footer">
            <h:commandButton
                value="#{ivy.cms.co('/Translations/Administration/Contacts/ButtonAddContact')}"
                actionListener="#{logic.addContact}" />
        </f:facet>
    </p:column>

</p:dataTable>
</h:form>

0 个答案:

没有答案