【问题标题】:encodeAll method doesn't get called when composite component is placed inside a PrimeFaces p:dialog当复合组件放置在 PrimeFaces p:dialog 中时,不会调用 encodeAll 方法
【发布时间】:2013-03-07 18:55:12
【问题描述】:

我已经在 PrimeFaces 对话框中测试了 Balusc 的 inputDate 组件:Composite component with multiple input fields encodeAll 方法根本没有被调用,选择框也没有被初始化。复合组件在放置在文章中所示的表单中时可以正常工作。

为什么encodeAll 在对话框中不起作用,如何解决?

编辑 1

我使用 Mojarra 2.1.13 和 PrimeFaces 3.4.2。

编辑 2 这是我真实项目中的一个示例。我使用您的组件来了解复合组件。我有一个视图帐户,带有一个数据表和一个工具栏。按添加应该会打开一个带有自定义向导的对话框。对话框有自己的形式,但不显示向导。

accounts.xhtml

<h:form id="form">
    <ui:include src="/WEB-INF/flows/accounts/accountsTable.xhtml" />    
</h:form>
<ui:include src="/WEB-INF/flows/accounts/mainDialog4.xhtml" />  

accountsTable.xhtml

<p:dataTable id="accounts" ... />  

<p:toolbar>
    <p:toolbarGroup align="left">
        <p:commandButton value="Add"
            action="#{accountsBean.initializeEntity}"
            process="@this" update=":actionsDialog4"
            oncomplete="actionsDialogWidget4.show()">
            <f:setPropertyActionListener value="#{2}"
                target="#{accountsBean.operation}" />
            <f:setPropertyActionListener value="accountsBean"
                target="#{sessionScope.beanName}" />
        </p:commandButton>
    </p:toolbarGroup>
 </p:toolbar>

mainDialog4.xhtml

<p:dialog id="actionsDialog4" widgetVar="actionsDialogWidget4" dynamic="true"
    modal="true">       
    <h:form>
    <costom:actionWizard name="wizard" widgetVar="wiz" bean="#{accountsBean}" header="#{accountsBean.entityHeader}" />
    </h:form>
</p:dialog>

【问题讨论】:

  • 无法在 Tomcat 7.0.37 上使用 Mojarra 2.1.20 和 PrimeFaces 3.5 重现它。在未来的问题中,请提及所使用的确切库 impl/versions 并包括 SSCCE
  • 添加了图书馆信息。
  • 现在是 SSCCE。我至少不能用&lt;h:body&gt;中的这个最小的sn-p重现它:&lt;p:button value="dialog" onclick="foo.show();return false;"/&gt;&lt;p:dialog widgetVar="foo"&gt;&lt;h:form&gt;&lt;my:inputDate/&gt;&lt;/h:form&gt;&lt;/p:dialog&gt;
  • 我进行了不同的测试:&lt;h:form&gt;&lt;p:commandButton process="@this" value="dialog" oncomplete="foo.show()" update="mainDialog"/&gt;&lt;p:dialog id="mainDialog" widgetVar="foo"&gt;&lt;my:inputDate/&gt;&lt;/p:dialog&gt;&lt;/h:form&gt;
  • 这是无效的对话框语法。对话框不应以任何形式放置,而应有自己的形式。

标签: java jsf-2 primefaces dialog composite-component


【解决方案1】:

这是由于 PrimeFaces CoreRenderer 没有在 renderChildren() 方法中调用 UIComponent#encodeAll(),而是分别调用了 encodeBegin()encodeChildren()encodeEnd()。所以当它被声明为 PrimeFaces 组件的直接子组件时它总是会失败,但当它被声明为标准 JSF 组件的直接子组件时它会起作用。

如果您在encodeBegin() 而不是encodeAll() 中执行该工作,那么它应该可以工作。我已经相应地更新了复合组件文章。

在不相关的注释中,&lt;p:dialog&gt; 应该有自己的形式。

【讨论】:

    猜你喜欢
    • 2013-03-14
    • 2012-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-12
    • 2013-11-20
    • 1970-01-01
    相关资源
    最近更新 更多