1
votes

In a primefaces dialog I show a form with some input fields initially. If the user clicks a button an image or pdf is opened and the dialog is separated with a p:layout. For this I include the rendering of the input fields inside editProperty.xhtml and include it two times in the dialog. Inside a panelGroup to show input fields only and also inside a p:layout. I excluded the panelGroup and the layout with the rendered attribute. So my expectation is that only the dialog is shown with the layout or with the panelgroup. The initial UI shows it without the p:layout but the fields are rendered twice.

<o:form id="editPropertyFormId">
<p:dialog id="editPropertyDialogId" widgetVar="editPropertyDialogVar" modal="true">
    <!-- <c:if test="#{editPropertyContentBL.isContentViewerCollapsed() == false}"> -->
    <p:layout id="editPropertiesLayoutId" style="width: 100%; height: 100%;" onResize="adjustContentViewerSize();"
        widgetVar="editPropertiesLayoutVar" rendered="#{editPropertyContentBL.contentViewerCollapsed == false}">
        <p:layoutUnit id="editPropertiesFieldsLayoutId" position="west" resizable="true" size="400"
            style="padding-right: 5px !important;" collapsible="false">
            <ui:include src="/sections/edit/editProperty.xhtml">
                <ui:param name="idPrefix" value="editPropsInLayout" />
                <ui:param name="editPropertyBLInstance" value="#{editPropertyBL}" />
                <ui:param name="editPropertyContentBLInstance" value="#{editPropertyContentBL}" />
            </ui:include>
        </p:layoutUnit>
        <p:layoutUnit id="editPropertiesContentViewerLayoutId" position="center" resizable="true"
            styleClass="contentViewerLayout">
            <ui:include src="/sections/content/contentViewer.xhtml" />
        </p:layoutUnit>
        </p:layout>
        <!-- </c:if> -->

        <!-- <c:if test="#{editPropertyContentBL.isContentViewerCollapsed() == true}"> -->
        <h:panelGroup rendered="#{editPropertyContentBL.contentViewerCollapsed == true}">
            <ui:include src="/sections/edit/editProperty.xhtml">
                <ui:param name="idPrefix" value="editProps" />
                <ui:param name="editPropertyBLInstance" value="#{editPropertyBL}" />
                <ui:param name="editPropertyContentBLInstance" value="#{editPropertyContentBL}" />
                </ui:include>
        </h:panelGroup>
        <!-- </c:if> -->
</p:dialog>

If I use c:if (uncommented in the code), it seems that the ui:parameter does not work because an update inside editProperty.xhtml does not work:

<p:inputText id="#{idPrefix}editPropertyChoiceListValueId"...
<p:commandButton update="#{idPrefix}editPropertyChoiceListValueId"

I get an exception that "editPropseditPropertyChoiceListValueId" cannot be found. Probably there is problem with ui:include/ui:param inside c:if?

Thanks Oliver

1
It is a primitive boolean and during debugging it is on the initial build of the UI always in its initial state true. Only the button click changes it to false.opfau

1 Answers

0
votes

The problem of the twice rendered contents was databinding of a dataTable inside an included xhtml:

<h:dataTable binding="#{editPropertyMainTableBinding}"

I used this to get the current row index:

<ui:param name="curDummyCssClass" value="editPropertyChoiceDummyCssClass#{editPropertyMainTableBinding.rowIndex}" />

After I eliminated this the double rendering was gone. Also the UI rendering seems to be much faster. Also I removed the "c:if test" and the rendered stuff by putting the contents in separate xhtml files and include it:

<ui:include src="#{editPropertyContentBL.contentViewerCollapsed == true ? '/sections/dialog/editPropertyDialogContent.xhtml' : '/sections/dialog/editPropertyWithContentViewerDialogContent.xhtml'}" />

I don't think this has to do with the double rendering, but removes the unloved c:if tag.