0

I've recently upgraded Primefaces from 4.0 to 5.1 and after that dialogs are not being shown after clicking the commandButton. It works with dynamic="false" but I need it to be lazy loaded. ExampleBean is sessionScoped and i'm using JSF 2.2. Can someone help me solve this?

<ui:composition template="/template/common/pagelayout.xhtml"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://xmlns.jcp.org/jsf/core"
    xmlns:h="http://xmlns.jcp.org/jsf/html"
    xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
    xmlns:p="http://primefaces.org/ui"
    xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
    xmlns:ez="http://xmlns.jcp.org/jsf/composite">

    <ui:define name="content">    
        <h:form id="form">
            <p:commandButton type="button" value="Log" onclick="PF('dlgLog').show();" icon="botaoLog" />
        </h:form>

        <p:dialog header="HEADER" widgetVar="dlgLog" resizable="false" modal="true" height="500" width="1000" dynamic="true">
            <ui:include src="logPage.xhtml"/>
        </p:dialog>
    </ui:define>
</ui:composition>

logPage.xhtml

<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:h="http://xmlns.jcp.org/jsf/html"
  xmlns:f="http://xmlns.jcp.org/jsf/core"
  xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
  xmlns:p="http://primefaces.org/ui">

  <h:head>
  </h:head>

  <h:body>
    <h:form id="formlog">
        <p:dataTable var="log" value="#{exampleBean.logs}" emptyMessage="Empty">

            <p:column headerText="Header1" width="10%">  
                <h:outputText value="#{log.date}">
                    <f:convertDateTime pattern="dd/MM/yyyy - HH:mm"/>
                </h:outputText>
            </p:column>

            <p:column headerText="Header2" width="10%">  
                <h:outputText value="#{log.op}" />  
            </p:column>

            <p:column headerText="Header3">
                <p:outputLabel value="#{log.name}"/>
            </p:column>

        </p:dataTable>
    </h:form>
  </h:body>
</html>
Vinicius
  • 1
  • 1
  • 4
  • I think you should make it ui:composition : http://stackoverflow.com/questions/4792862/how-to-include-another-xhtml-in-xhtml-using-jsf-2-0-facelets – Jaqen H'ghar Jan 21 '15 at 07:32
  • Thanks @JaqenH'ghar . Tried to make it ui:composition but it didn't work. I can see by the hibernate generated sql in console that the content in page logPage.xhtml is loaded from db but the dialog still not being shown. – Vinicius Jan 21 '15 at 14:12
  • See my answer here; related: https://stackoverflow.com/a/53015102/1599699 – Andrew Oct 26 '18 at 19:22

2 Answers2

0

Finally figured what the problem was. Just removed the <h:head> tag from logPage.xhtml and it worked! Not sure I know the reason though, probably has something to do with <ui:include> expecting a composition which shouldn't have a <h:head> tag.

Alexander Vogt
  • 17,879
  • 13
  • 52
  • 68
Vinicius
  • 1
  • 1
  • 4
0

More specifically, you removed the h:head tag (and I found out ;-). Between the versions you used, PF created it's own h:head renderer which differs from the default implementions in code jsf libraries hence the difference in behaviour (assuming your jsf impl stayed the same).

Kukeltje
  • 12,223
  • 4
  • 24
  • 47