【问题标题】:<p:growl> causes "The form component needs to have a UIForm in its ancestry"<p:growl> 导致“表单组件需要在其祖先中有一个 UIForm”
【发布时间】:2016-07-14 21:03:38
【问题描述】:

根据this 的回答,在启用开发模式时消除该弹出窗口的方法如下。

<h:form id="f1" prependId="false" onsubmit="document.getElementById('f1').action='j_security_check';">                      
    ...
</h:form>

但是当我添加 &lt;p:growl&gt; 时它对我不起作用

<h:form id="f1" prependId="false" onsubmit="document.getElementById('f1').action='j_security_check';">                      
    <p:growl id="growl" showDetail="true" sticky="true" />
    ...
</h:form>

我该如何解决?

我的配置:Wildfly 8、Mojara 2.2.x(服务器运行时)、PrimeFaces 5.3

【问题讨论】:

  • 是您所指的弹出窗口“表单组件需要在其祖先中有一个 UIForm。建议:将必要的组件包含在
    中”弹出窗口中描述的链接问题?我在您的摘录中看不到任何标签应该导致该消息;它们都包裹在h:form 中。页面上是否还有其他组件未包含在您的摘录中?
  • @Chatoyancy 上述 sn-p 不包含任何其他组件,除了您在问题中看到的组件。如果评论 p:growl 组件,该警告消息就会消失

标签: forms jsf jsf-2 primefaces


【解决方案1】:

在我的情况下,以下解决了问题:

<p:menubar id="pmenubar">
    <p:menuitem value="Inicio" url="${facesContext.externalContext.requestContextPath}/hola.xhtml"
                    icon="ui-icon-home" />
</p:menubar>

我忘了关闭这个组件。您可能已经注意到,该组件既没有actionListener 也没有action,因此您需要将其括在一个表单中:

<h:form>
    <p:menubar id="pmenubar">
        <p:menuitem value="Inicio" url="${facesContext.externalContext.requestContextPath}/productos/crear-producto.xhtml"
                    icon="ui-icon-home" />
    </p:menubar>
</h:form>

【讨论】:

    猜你喜欢
    • 2016-11-17
    • 2011-12-06
    • 2012-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-21
    • 2020-11-23
    相关资源
    最近更新 更多