Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

encodeAll method doesn't get called when composite component is placed inside a PrimeFaces p:dialog

I have tested Balusc's inputDate component: Composite component with multiple input fields inside a PrimeFaces dialog. The encodeAll method is not called at all and the select boxes are not initialized. The composite component works fine when placed in a form as shown in the article.

Why encodeAll doesn't work inside a dialog and how can be fixed?

EDIT 1

I use Mojarra 2.1.13 and PrimeFaces 3.4.2.

EDIT 2 Here is a sample from my real project. I used your component to learn about composite components. I have a view accounts, with a datatable and a toolbar. Pressing Add should open a dialog with a custom wizard. The dialog has its own form, but the wizard is not displayed.

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>
like image 382
Seitaridis Avatar asked Jun 17 '26 20:06

Seitaridis


1 Answers

This is caused by the PrimeFaces CoreRenderer not calling UIComponent#encodeAll() in renderChildren() method, but encodeBegin(), encodeChildren() and encodeEnd() individually. So it will always fail when it's declared as direct child of a PrimeFaces component, but it will work when it's declared as direct child of a standard JSF component.

If you perform the job in encodeBegin() instead of encodeAll(), then it should work. I have updated the composite component article accordingly.

On an unrelated note, the <p:dialog> should have its own form.

like image 77
BalusC Avatar answered Jun 20 '26 10:06

BalusC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!