choquero70
choquero70

Reputation: 4754

jsf ajax request recreates viewscoped bean

I use JSF 2.2 and Primefaces 3.5, and I have a problem with ajax request when I update parent component:

<h:panelGroup id="PAG_CARTELERA" layout="block">
<h:form id="FRM_CARTELERA">
        <h:panelGroup rendered="#{!carteleraController.existeCookieCinePref}">
            <ui:include src="/paginas/cartelera/cinePreferidoIn.xhtml" />
        </h:panelGroup>
        <h:panelGroup rendered="#{carteleraController.existeCookieCinePref}">
            <ui:include src="/paginas/cartelera/carteleraOut.xhtml" />
        </h:panelGroup>
</h:form>
</h:panelGroup>

In the page carteleraOut.xhtml I have:

<p:calendar id="CART_FECHA" value="#{carteleraController.fechaConsulta}"
                                maxlength="10"
                                size="10"
                                locale="es"
                                pattern="dd/MM/yyyy"
                                navigator="true"
                                showOn="button"
                                showButtonPanel="true">
                                <f:converter converterId="calendarConverter" />
                                <p:ajax process="@this" update=":PAG_CARTELERA" event="dateSelect" listener="#{carteleraController.consultarOtroDiaAction}" />

In the "consultarOtroDiaAction" listener I set the "existeCookieCinePref" boolean field and return void to stay in the same view ("carteleraController" is a ViewScoped a bean).

However the first ajax request when I change the value of the p:calendar component works fine, but the following requests recreates the ViewScoped bean.

Why is this?

Thank you.

NOTE: If in the p:calendar ajax request I update a component of the carteleraOut.xhtml itself, it works, but if I update the whole PAG_CARTELERA panelgroup, it recreates the bean.

Upvotes: 1

Views: 941

Answers (1)

&#214;mer Faruk Kurt
&#214;mer Faruk Kurt

Reputation: 570

can you try h:panelGroup inside of h:form

<h:form id="FRM_CARTELERA">
<h:panelGroup id="PAG_CARTELERA" layout="block">
        <h:panelGroup rendered="#{!carteleraController.existeCookieCinePref}">
            <ui:include src="/paginas/cartelera/cinePreferidoIn.xhtml" />
        </h:panelGroup>
        <h:panelGroup rendered="#{carteleraController.existeCookieCinePref}">
            <ui:include src="/paginas/cartelera/carteleraOut.xhtml" />
        </h:panelGroup>
</h:panelGroup>
</h:form>

Upvotes: 1

Related Questions