如何避免commandButton呈现表单提交中的所有组件?

时间:2013-11-07 09:31:00

标签: jsf primefaces form-submit

我正在研究JSF primefaces,因为我在提交表单时遇到问题

问题描述:

我正在使用primefaces tapView面板,因为每次点击我都有一组带有submitButton的输入字段,其中我设置所有字段是强制性的,如果我输入值一个tap(tap1)字段并给出提交意味着动作是没有被触发,原因是因为我设置了另一个tap(tap2)字段是强制性的,所以表单没有得到提交。

我的JSF代码:

<h:form>
<p:tabView  >
<p:tab id="tap1" title="Tap1">

    <h:panelGrid>
        <h:panelGroup id="ip_leave">
    <h:outputText value="From"  styleClass="op1" style="margin-right:10px;" />
    <p:calendar pattern="dd/MM/yyyy" effect="drop" value="#{leavehistory.leaveFrom}" required="true" size="10"/>
    <h:outputText value="To"  styleClass="op1" style="margin-left:40px;margin-right:10px;"/>
    <p:calendar pattern="dd/MM/yyyy" effect="drop" value="#{leavehistory.leaveTo}" required="true" size="10"/>
    <p:commandButton value="Get"  actionListener="#{leavehistory.submitLeaveHistory}" update="tap1" style="margin-left:40px;" />
    </h:panelGroup>
    </h:panelGrid>
</p:tab>
<p:tab id="tap2" title="Tap2">
    <h:panelGrid id="ip_reject">
            <h:panelGroup >
            <h:outputText value="From"  styleClass="op1" style="margin-right:10px;" />
            <p:calendar pattern="dd/MM/yyyy" effect="drop" value="#{leavehistory.rDateFrom}" required="true" size="10"/>
            <h:outputText value="To"  styleClass="op1" style="margin-left:40px;margin-right:10px;"/>
            <p:calendar pattern="dd/MM/yyyy" effect="drop" value="#{leavehistory.rDateTo}" required="true" size="10"/>
            <p:commandButton value="Get"  actionListener="#{leavehistory.submitRejectedLeaveHistory}" update="tap2" style="margin-left:40px;" />
            </h:panelGroup>
            </h:panelGrid>
</p:tab>
</p:tabView>

我的问题是如何仅在一个水龙头中部分提交字段?


已更新:

最后使用了在commandButton中添加process属性

<p:commandButton value="Get" actionListener="#{leavehistory.submitLeaveHistory}" update="tap1" style="margin-left:40px;" />

1 个答案:

答案 0 :(得分:1)

使用p:commandButton上的'process'属性命名要处理的组件或其父命名容器。此外,您可能还希望将属性“partialSubmit”设置为true。这将阻止PF将这些字段发送到无论如何都不会被处理的服务器。

相关问题