我已经在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>
最佳答案
这是由于PrimeFaces CoreRenderer
没有在UIComponent#encodeAll()
方法中调用renderChildren()
而是在encodeBegin()
,encodeChildren()
和encodeEnd()
中单独调用而引起的。因此,当它被声明为PrimeFaces组件的直接子代时,它总是会失败,但是当它被声明为标准JSF组件的直接子代时,它将起作用。
如果您使用encodeBegin()
而不是encodeAll()
来执行作业,那么它应该可以工作。我已经相应地更新了复合组件文章。
不相关的说明是,<p:dialog>
应该具有自己的形式。
关于java - 将复合组件放置在PrimeFaces p:dialog中时,未调用encodeAll方法,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/15493746/