0

i want to include dynamically an xhtml page into another one. I choose the page to include from a combo which list different pages i could include, and the included page appears by AJAX in a panel.

The included page contains a If i submit it : the first time only PHASE 1 and 6 are executed. If i submit a second time : all is ok and considered as a POST with all the phases. Why ?

I have been explained it was a "normal" bug in JSF 2.0/2.1 but i here i use JSF 2.2.7 with Tomcat7 (no cdi)

What is wrong ?

INFO IN pour /m-page-include-v1/process.faces ¤¤¤¤¤ POST
INFO  AJAX BEFORE RESTORE_VIEW 1 for viewId=null 
INFO  AJAX AFTER  RESTORE_VIEW 1 for viewId=/process.xhtml
INFO  AJAX BEFORE RENDER_RESPONSE 6 for viewId=/process.xhtml 
INFO  AJAX AFTER  RENDER_RESPONSE 6 for viewId=/process.xhtml

INFO IN pour /m-page-include-v1/process.faces ¤¤¤¤¤ POST
INFO  AJAX BEFORE RESTORE_VIEW 1 for viewId=null 
INFO  AJAX AFTER  RESTORE_VIEW 1 for viewId=/process.xhtml
INFO  AJAX BEFORE APPLY_REQUEST_VALUES 2 for viewId=/process.xhtml 
INFO  AJAX AFTER  APPLY_REQUEST_VALUES 2 for viewId=/process.xhtml
INFO  AJAX BEFORE PROCESS_VALIDATIONS 3 for viewId=/process.xhtml 
INFO  AJAX AFTER  PROCESS_VALIDATIONS 3 for viewId=/process.xhtml
INFO  AJAX BEFORE RENDER_RESPONSE 6 for viewId=/process.xhtml 
INFO  AJAX AFTER  RENDER_RESPONSE 6 for viewId=/process.xhtml

process.xhtml "main" page :

<h:form id="chooseForm">
    <h:panelGrid columns="2">
        <h:outputLabel value="Choose your page to include" />
        <h:selectOneMenu id="pageList" value="#{anyPageBean.page}">
            <f:selectItems value="#{anyPageBean.pageList}" var="w" itemValue="#{w}" itemLabel="#{w}" />
            <f:ajax event="change" execute="@form" render=":panelForDynaPage  :globalMessages" />
        </h:selectOneMenu>
    </h:panelGrid>
</h:form>

<h:panelGroup id="panelForDynaPage">
    <ui:include id="includeContenu" src="#{anyPageBean.page}" />
</h:panelGroup>

included page :

<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">

    <h:form id="userForm">
        <h:messages styleClass="messages" id="messages" />

        <h:panelGrid columns="2">
            <h:outputLabel value="#{i18n.name}" />
            <h:panelGroup>
                <h:inputText id="name" value="#{userForm.name}" label="#{i18n.name}" />
            </h:panelGroup>
        </h:panelGrid>

        <h:commandButton actionListener="#{userAction.checkListener()}" value="ok" id="check">
            <f:ajax execute="@form" render="@form" />
        </h:commandButton>
    </h:form>

</ui:composition>
BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
Gauthier Peel
  • 1,135
  • 11
  • 31
  • 1
    I hope this link could helop you http://stackoverflow.com/questions/2118656/hcommandlink-hcommandbutton-is-not-being-invoked Point 7 might relate to you. – Srikanth Ganji Jul 08 '14 at 07:22
  • You are right Ganji, Point 7 seems to apply. What a shame that a bug with a solution detected in 2.0 should not be corrected in 2.2 ! – Gauthier Peel Jul 08 '14 at 10:36

1 Answers1

1

As stated by @Ganji the point 7 in the link is my problem.

You could find a solution here

Also in this link is described what i think is the easiest solution : to include @BalusC Omnifaces > 1.7. I tried version 1.8.1 and just added the following to my "main" page, and it works like a charm !

<h:body>
<!-- should be placed inside h:body  -->
<h:outputScript library="omnifaces" name="fixviewstate.js" target="head" />
Community
  • 1
  • 1
Gauthier Peel
  • 1,135
  • 11
  • 31