【问题标题】:How to avoid commandButton to render all components in form submit?如何避免 commandButton 在表单提交中呈现所有组件?
【发布时间】:2013-11-07 09:30:59
【问题描述】:

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

问题描述:

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

我的 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属性

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

【问题讨论】:

    标签: jsf primefaces form-submit


    【解决方案1】:

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

    【讨论】:

    • 你能举一个例子来说明如何使用process属性
    • 呃,你的意思是我能不能给你举个例子?我不打算绘制任何东西,尤其是不与“一些例子”一起;)
    猜你喜欢
    • 2019-08-11
    • 1970-01-01
    • 2022-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-05
    相关资源
    最近更新 更多