提交表单时从流程中排除组件(在h:panelGrid中有效,但在p:panelGrid中无效) [英] exclude component from process when form is submited (works in h:panelGrid but not in p:panelGrid)

查看:92
本文介绍了提交表单时从流程中排除组件(在h:panelGrid中有效,但在p:panelGrid中无效)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问:使用质数表提交表单时,我应该使用什么语法来排除组件?

Q: What syntax should i use to exclude a component when submitting a form using primefaces?

使用process属性,我知道如何包含组件.

Using the process attribute i know how to include components.

<h:inputText id="included"/>
<p:commandButton value="button" process="included" actionListener="#{myBean.doStuff}/>

我一直在尝试类似于此处答案中使用的语法:

I've been trying to play around with syntax similiar to what is used in the answer here: How to exclude child component in ajax update of a parent component? but cant get it to work

<h:inputText id="notIncluded" styleClass="notIncluded"/>
<p:commandButton ... process="@(form :not(.notIncluded))"/>

编辑(做功课并添加实际的工作示例): 在玻璃鱼3.1.2.2和素面3.4.2上

Edit (doing the homework and adding an actual working example): On glassfish 3.1.2.2 and primefaces 3.4.2

当我进一步观察时,该排除在h:panelGrid内部运行良好

When i looked further, the exclusion works fine inside h:panelGrid

<h:form id="aForm">
    <h:panelGrid columns="2">
        <p:inputText id="inc" styleClass="included" required="true" />
        <p:message for="inc" />
        <p:inputText id="notInc" styleClass="notIncluded" required="true" />
        <p:message for="notInc" />

        <p:commandButton value="submit" process="@(form :not(.notIncluded))"
            update=":aForm" />
    </h:panelGrid>
</h:form>

但不再被排除在类似的p:panelGrid内

But is no longer excluded inside a similar p:panelGrid

<h:form id="aForm">
    <p:panelGrid columns="2">
        <p:inputText id="inc" styleClass="included" required="true" />
        <p:message for="inc" />
        <p:inputText id="notInc" styleClass="notIncluded" required="true" />
        <p:message for="notInc" />

        <p:commandButton value="submit" process="@(form :not(.notIncluded))"
            update=":aForm" />
    </p:panelGrid>
</h:form>

推荐答案

我检查了您的示例,如果您查看页面源代码,您会注意到p:panelGrid创建具有ID的表.有点奇怪,但是 jQuery选择器在表具有ID时不会访问child.如果我删除表格ID,则按钮可以正常工作.所以我的解决方案是给panelGrid一个id并在选择器中使用这个id. p:panelGrid将为表赋予相同的ID,但您需要确保将prependId="false"属性添加到h:form:

I have checked your examples, if you review page source your will notice that p:panelGrid creates table with id. Little bit strange but jQuery selector doesnt access childs when table has an id. If I remove table Id then button works fine. So my solution was giving an id to panelGrid and using this id in selector. p:panelGrid will give same id to table but you need to make sure you add prependId="false" attribute into your h:form:

<h:form id="aForm" prependId="false">
    <p:panelGrid columns="2" id="myGrid">
        <p:inputText id="inc" styleClass="included" required="true" />
        <p:message for="inc" />
        <p:inputText id="notInc" styleClass="notIncluded" required="true" />
        <p:message for="notInc" />

        <p:commandButton value="submit" process="@(#myGrid :not(.notIncluded))"
            update=":aForm" />
    </p:panelGrid>
</h:form>

这篇关于提交表单时从流程中排除组件(在h:panelGrid中有效,但在p:panelGrid中无效)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆