Evgeny Mironenko
Evgeny Mironenko

Reputation: 439

JSF rendered method is not invoked in the second time

I have next a4j:jsFunction

<a4j:jsFunction name="renderOnBusinessErrorEvent" execute="@none" bypassUpdates="true" immediate="true"
            render="securityForm">
        </a4j:jsFunction>

and JSF form with some dialog inside

<h:form id="securityForm">
      <h:panelGroup rendered="#{someCondition}">
      ......
      </h:panelGroup>
    </h:form>

In my business logic it has to be executed twice consequently. In the first time all is fine. Rendered method is invoked and the expected dialog is present on the page. In the second time rendered method is not invoked, but model has been changed and I expect that dialog will not be present on the page. I supposed that it's some richfaces issue and I tried to use f:ajax

<a4j:jsFunction name="renderOnBusinessErrorEvent" execute="@none" bypassUpdates="true" immediate="true">
            <f:ajax event="begin" render=":securityForm"/>
        </a4j:jsFunction>

but unsuccessfully. Rendered method still not invoked in the second time. What is it? Some JSF optimization or bug? What's the workaround? JSF version 2.1.19

Upvotes: 0

Views: 880

Answers (1)

Evgeny Mironenko
Evgeny Mironenko

Reputation: 439

The problem was in <h:panelGroup rendered="#{someOtherCondition}"> over h:form which equals false after the first rendering (ON THE SERVER SIDE). However, this panelGroup is not part of rendering. So, my code:

<h:panelGroup rendered="#{someOtherCondition}">
    <h:form id="securityForm">
          <h:panelGroup rendered="#{someCondition}">
          ......
          </h:panelGroup>
     </h:form>
</h:panelGroup>
<h:form>
    <a4j:jsFunction name="renderOnBusinessErrorEvent" execute="@none" bypassUpdates="true" immediate="true"
            render="securityForm">
    </a4j:jsFunction>
</h:form>

Before calling renderOnBusinessErrorEvent() I'm changing the value of someOtherCondition from true to false, but I don't rerender this element. Actually, on the server side this element is already missing. Looks like it's JSF feature, but is it specificated somewhere?

Upvotes: 0

Related Questions