preRenderView not firing with ui:include

非 Y 不嫁゛ 提交于 2019-12-24 17:20:29

问题


I have a typical JSF templated menu structure and page. Below is the code of my main page

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

<ui:composition template="/templates/internal3section.xhtml">
<ui:define name="events">
    <f:event listener="#{mainBean.entryGate}" type="preRenderView" />
</ui:define>

<ui:define name="headerarea">
<p:panel style="margin:10px;">
    <h:outputText value="WelCome "></h:outputText><br/>
    <h:outputText value="You are using the application to view data for"></h:outputText><br/>
    <p:selectOneMenu value="#{mainBean.selectedId}">
        <p:ajax update=":extPane:content" />
        <f:selectItems value="#{mainBean.ids}" var="id" 
                       itemLabel="#{id.name} 
                       itemValue="#{id.entityId}"/>
    </p:selectOneMenu>
</p:panel>
</ui:define>
<ui:define name="contents">
<h:form id="extPane">
<div>
        <p:menubar style="margin-bottom:5px;">
            <p:menuitem value="Schedule" icon="ui-icon-star" ajax="true"
                actionListener="#{mainBean.setSelectedPage('schedule')}"
                update="content">
            </p:menuitem>
            <p:menuitem value="Assignments" icon="ui-icon-star" ajax="true"
                actionListener="#{mainBean.setSelectedPage('Assignments')}"
                update="content">
            </p:menuitem>
            <p:menuitem value="Write to Us" icon="ui-icon-star" ajax="true"
                actionListener="#{mainBean.setSelectedPage('writetous')}"
                update="content">
            </p:menuitem>
        </p:menubar>
</div>
<div>
<p:panel>
    <p:outputPanel id="content" layout="block" autoupdate="true" style="border-style: none; padding: 0;">
        <c:if test="#{mainBean.selectedPage!=null}">
            <ui:include src="external/#{mainBean.selectedPage}.xhtml" />
        </c:if>
    </p:outputPanel>
</p:panel>  
</div>
</h:form>
</ui:define>

I have two menu types, one that changes report type and the other that changes the report data (based on entity Id).

My include pages have preRenderEvent to take care of updates based on changes to entityId using the top selectOneMenu.

Here is the code for one of my include xhtml

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:em="http://java.sun.com/jsf/composite/emcomp"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core">


    <f:event listener="#{noteBean.loadRequests}" type="preRenderView" />

<h:head>
</h:head>
<h:body>
 <div>
 <p:panel header="Send a New Note  for #{mainBean.selectedEntity.name}" id="notePanel" toggleable="TRUE" collapsed="FALSE" >    
...
</p:panel>
</div>
 </h:body>

My problem is that the preRenderView event in the include files is not fired. They are not fired even for the first time when the page is displayed.

I am not sure if this is because ui:include is happening thru ajax request. I presume page load kind of events are not fired when ajax updates happen.

I am not able to use actionEvent against menu items as the page needs to be updating itself based on entity selection. Hence the only way is to fire the event preRenderView event.

Please let me know

  • If there is something wrong with the way I am trying to get the preRenderView event to fire from a ui:include file.
  • Is there any other way to make the report update to work?

来源:https://stackoverflow.com/questions/12543405/prerenderview-not-firing-with-uiinclude

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!