Uploaded image for project: 'RichFaces'
  1. RichFaces
  2. RF-12145

RF4.2: Render and Oncomplete attributes not evaluated after invokeApplication if command is not rendered anymore

    Details

    • Type: Bug
    • Status: Resolved (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 4.2.0.Final
    • Fix Version/s: 4.3.0.M3
    • Component/s: component-a4j-core, core
    • Labels:
      None
    • Environment:

      MyFaces 2.1.6 / Mojarra 2.1.7
      Tomcat 6.0.35 / 7.0.26

    • Sprint:
      Sprint - Critical bug fixes, 4.3.0.M3 - EDT and AJAX
    • Steps to Reproduce:
      Hide
      1. download sample WAR file and add Richfaces libs to it
      2. start Apache Tomcat 6/7 and deploy the WAR file
      3. open http://localhost:8080/zOnc42WithLibs/faces/oncomplete.xhtml
      4. click on the "RichFaces Post" button
        • alert window "after action listener" is shown (correct)
      5. click on the "Clear" button
      6. disable "Post button rendered" checkbox
      7. click on the "RichFaces Post" button
        • alert window "before action listener" is shown (wrong)
      Show
      download sample WAR file and add Richfaces libs to it start Apache Tomcat 6/7 and deploy the WAR file open http://localhost:8080/zOnc42WithLibs/faces/oncomplete.xhtml click on the "RichFaces Post" button alert window "after action listener" is shown (correct) click on the "Clear" button disable "Post button rendered" checkbox click on the "RichFaces Post" button alert window "before action listener" is shown (wrong)
    • Story Points:
      3

      Description

      Sample use case:
      The last page of a wizard contains a commandButton with an EL expressions in the oncomplete attribute and in the render attribute.
      This button renders an outer component in order to close the wizard. The button itself is not rendered anymore after clicking it.
      As a consequence the EL expressions of the oncomplete attribute and of the render attribute is not evaluated after the invocation of an actionListener.

      This worked well with richfaces 3.3.3, therefore it's a critical regression.

      I'll attach a sample webApp for richfaces 4.2 and for riochfaces 3.3.3

      Note that the render attribute of f:ajax is evaluated correctly.

      These attributes of the clicked command must be evaluated in phase render response in all cases.


      "OncController.java"

      package com;
       
      import java.util.Map;
       
      import javax.faces.bean.ManagedBean;
      import javax.faces.bean.SessionScoped;
      import javax.faces.context.FacesContext;
      import javax.faces.event.ActionEvent;
       
      @ManagedBean(name = "OncController")
      @SessionScoped
      public class OncController
      {
       
        private boolean innerShown = true;
        
        private int calls = 0;
       
        public OncController()
        {
       
        }
       
        public boolean isInnerShown()
        {
          return innerShown;
        }
       
        public void setInnerShown(boolean aInnerShown)
        {
          innerShown = aInnerShown;
        }
        
        public void clear(final ActionEvent ae)
        {
          innerShown=true;
          calls=0;
        }
       
        public void doIt(final ActionEvent ae)
        {
          final Map<String, Object> requestMap = FacesContext.getCurrentInstance().getExternalContext()
              .getRequestMap();
          requestMap.put("key1", "alert('after actionListener');");
          requestMap.put("key2", "group2");
          calls++;
        }
       
        public String getOncomplete()
        {
          final Map<String, Object> requestMap = FacesContext.getCurrentInstance().getExternalContext()
              .getRequestMap();
          final String value = (String) requestMap.get("key1");
          if (value != null)
          {
            return value;
          }
          else
          {
            return "alert('before actionListener');";
          }
        }
       
        public String getRenderIdsRichfaces()
        {
          final Map<String, Object> requestMap = FacesContext.getCurrentInstance().getExternalContext()
              .getRequestMap();
          final String value = (String) requestMap.get("key2");
          if (value != null)
          {
            return ","+value;
          }
          return"";
        }
        
        public String getRenderIdsFAjax()
        {
          final Map<String, Object> requestMap = FacesContext.getCurrentInstance().getExternalContext()
              .getRequestMap();
          final String value = (String) requestMap.get("key2");
          if (value != null)
          {
            return " " + value;
          }
          return"";
        }
        
       
        public int getCalls()
        {
          return calls;
        }
      }

      "oncomplete.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:a4j="http://richfaces.org/a4j"
            xmlns:rich="http://richfaces.org/rich"
            xmlns:c="http://java.sun.com/jsp/jstl/core">
       
      <ui:composition>
      <h:head><title>Oncomplete test</title></h:head>
      <h:body>
       
      <a4j:log mode="popup"/>
       
      <h:form id="myForm">
      Post button rendered:<h:selectBooleanCheckbox id="innerBool" value="#{OncController.innerShown}"/>
      <br/>
      <h:panelGroup id="outer">
        <c:if test="#{OncController.innerShown}">
          <a4j:commandButton value="RichFaces Post"  
                             actionListener="#{OncController.doIt}"
                             render="outer,details#{OncController.renderIdsRichfaces}" 
                             oncomplete="#{OncController.oncomplete}"/>
       
          <h:commandButton value="fAJAX Post"  
                           actionListener="#{OncController.doIt}">
            <f:ajax render="outer details#{OncController.renderIdsFAjax}"
                    execute="@form"/>
          </h:commandButton>                     
        </c:if>
      </h:panelGroup>
      <br/><br/>
      <h:panelGroup id="details">
      oncomplete: <h:outputText value="#{OncController.oncomplete}"/>
      </h:panelGroup>
      <br/><br/>
      <h:panelGroup id="group2">
      calls: <h:outputText value="#{OncController.calls}"/>
      </h:panelGroup>
      <br/><br/>
        <a4j:commandButton value="Clear"  
                           actionListener="#{OncController.clear}"
                           render="myForm" />
       
      </h:form>
      </h:body>
      </ui:composition>
      </html>

        Gliffy Diagrams

          Issue Links

            Activity

            Hide
            lfryc Lukáš Fryč added a comment -

            Michael, you really doesn't help us to get our job done effectively - there are several samples attached with this issue.

            Yes, I can simply investigate with your samples by c&p your sources to existing project - but I won't do so unless you will take a time and try a suggested workaround together with RF 4.3.0.M3, which is: use <a4j:outputPanel rendered="..." /> instead of <c:if />.

            I'm pretty sure it will work - if it doesn't work, then please come back to us and I will look at your sample (in case you'll tell me which sample is up to date).

            Thanks for understanding.

            Show
            lfryc Lukáš Fryč added a comment - Michael, you really doesn't help us to get our job done effectively - there are several samples attached with this issue. Yes, I can simply investigate with your samples by c&p your sources to existing project - but I won't do so unless you will take a time and try a suggested workaround together with RF 4.3.0.M3 , which is: use <a4j:outputPanel rendered="..." /> instead of <c:if /> . I'm pretty sure it will work - if it doesn't work, then please come back to us and I will look at your sample (in case you'll tell me which sample is up to date). Thanks for understanding.
            Hide
            mhn Michael Heinen added a comment -

            The rendered-checks are no real alternative for us.
            We have to reduce the size of the component tree via c-if at some spots in order to improve performance by removing complex structures from the view.
            The EL expressions of subcomponents with parents with attribute rendered=false are unfortunately evaluated again and again.
            Our app is grown over 7 years with hundreds of thousands lines of code. We migrated it from RF 3.3.3 to RF 4.2 and found this regression.

            I have attached a workaround with a phase listener and a patched ExtendedPartialViewContextImpl

            Yo don't have to copy and paste my sources into another project. The attached project zOnc42WithLibs.war is a complete web app (without the richfaces jars due to the upload size limitation) with one single xhtml file and two java classes. What do you expect? Only one java class?

            I helped you a lot by creating a small sample application, attaching a workaround and testing your fix against the milestone therefore I can't understand your comment at all.

            Show
            mhn Michael Heinen added a comment - The rendered-checks are no real alternative for us. We have to reduce the size of the component tree via c-if at some spots in order to improve performance by removing complex structures from the view. The EL expressions of subcomponents with parents with attribute rendered=false are unfortunately evaluated again and again. Our app is grown over 7 years with hundreds of thousands lines of code. We migrated it from RF 3.3.3 to RF 4.2 and found this regression. I have attached a workaround with a phase listener and a patched ExtendedPartialViewContextImpl Yo don't have to copy and paste my sources into another project. The attached project zOnc42WithLibs.war is a complete web app (without the richfaces jars due to the upload size limitation) with one single xhtml file and two java classes. What do you expect? Only one java class? I helped you a lot by creating a small sample application, attaching a workaround and testing your fix against the milestone therefore I can't understand your comment at all.
            Hide
            lfryc Lukáš Fryč added a comment -

            Hey Michael, in your last comment you finally gave me a hint why you are insisting to use <c:if />.

            Show
            lfryc Lukáš Fryč added a comment - Hey Michael, in your last comment you finally gave me a hint why you are insisting to use <c:if /> .
            Hide
            lfryc Lukáš Fryč added a comment -

            The fix I have made for 4.3 was correct, but for slightly different issue: the Render and Oncomplete weren't evaluated when conditionally rendered with rendered attribute of ancestor component.

            Therefore I have cloned this issue and we will investigate a possible fix further: RF-12730

            Show
            lfryc Lukáš Fryč added a comment - The fix I have made for 4.3 was correct, but for slightly different issue: the Render and Oncomplete weren't evaluated when conditionally rendered with rendered attribute of ancestor component. Therefore I have cloned this issue and we will investigate a possible fix further: RF-12730
            Hide
            mhn Michael Heinen added a comment -

            Thanks Lukáš!

            Show
            mhn Michael Heinen added a comment - Thanks Lukáš!

              People

              • Assignee:
                lfryc Lukáš Fryč
                Reporter:
                mhn Michael Heinen
              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 3 hours
                  3h
                  Remaining:
                  Remaining Estimate - 3 hours
                  3h
                  Logged:
                  Time Spent - Not Specified
                  Not Specified

                    Development