1

I have few views which will be conditionally rendered through ajax. Below is how my main.xhtml

<h:panelGroup id="page">
    <h:form>
        <h:panelGroup
            rendered="#{myCtrl.selectedPage == 'home'}">
                <ui:include src="/home.xhtml" />
        </h:panelGroup>
    </h:form>
    <h:form>
        <h:panelGroup
            rendered="#{myCtrl.selectedPage == 'bcn'}">
                <ui:include src="/reports.xhtml" id="reportPage" />
        </h:panelGroup>
    </h:form>
    <h:form id="remitid">
        <h:panelGroup
            rendered="#{myCtrl.selectedPage == 'btc'}">
            <ui:include src="/btc.xhtml" id="btcPage" />
        </h:panelGroup>
    </h:form>
</h:panelGroup>

So, based on commandLink click, these views will be rendered.

Disclaimer - Earlier this was richfaces project which was moved to primefaces and hence instead of a4j:support we are using p:ajax

in reports.xhtml I have some fields for which I have some p:ajax event for onchange.

<ui:composition lang="en" xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui">
    <div>
        <p:inputText styleClass="datepicker" id="fromDate"
            value="#{repBean.fromDate}">
            <p:ajax event="change" update="fromDate"
                listener="#{repBean.checkForValues}"></p:ajax>
        </p:inputText>
    </div>
    <div>
        <p:inputText styleClass="datepicker" id="toDate"
            value="#{repBean.toDate}">
            <p:ajax event="change" update="toDate"
                listener="#{repBean.checkForValues}"></p:ajax>
        </p:inputText>
    </div>
</ui:composition>

Whenever change event occurs, it refreshes the view [no reload] and renders initial screen. I've also tried adding process="@this"/process="@form" and partialSubmit="true" to p:ajax but that didn't help much. As per my observation while debugging, this is not hitting bean method at all.

What's actually happening here? Why isn't ajax not working as expected?

Please let me know if I've to add anymore details relating to the Question.

Guruprasad J Rao
  • 29,410
  • 14
  • 101
  • 200

0 Answers0