MyFaces Core
  1. MyFaces Core
  2. MYFACES-3542

The render attribute of AjaxBehavior should support late value expression evaluation

    Details

    • Type: New Feature New Feature
    • Status: Patch Available
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      The render attribute of AjaxBehavior should evaluated during post-back after 'Invoke Application' and before 'Render Response'. It's easly to add this feature with a own PartialViewContext. But there is no call to processPartial with 'Invoke Application'. The Phase 'Render Response' is too late if you are using c:if to skip components from the component tree. See attached example app and pictures.

      1. laterender.patch
        7 kB
        Dora Rajappan
      2. late-render-expression-4.png
        2 kB
        Bernd Bohmann
      3. late-render-expression-3.png
        4 kB
        Bernd Bohmann
      4. late-render-expression-2.png
        4 kB
        Bernd Bohmann
      5. late-render-expression-1.png
        3 kB
        Bernd Bohmann
      6. late-render-expression-0.png
        4 kB
        Bernd Bohmann
      7. late-render-expression.tgz
        6 kB
        Bernd Bohmann

        Activity

        Bernd Bohmann created issue -
        Bernd Bohmann made changes -
        Field Original Value New Value
        Description The render attribute of AjaxBehavior should evaluated during post-back after 'Invoke Application' and before 'Render Response'. It's easly to add this feature with a own PartialViewContext. But there is no call to processPartial with 'Invoke Application'. The Phase 'Render Response' is to late if you are using c:if to skip components from the component tree. See attached example app and pictures. The render attribute of AjaxBehavior should evaluated during post-back after 'Invoke Application' and before 'Render Response'. It's easly to add this feature with a own PartialViewContext. But there is no call to processPartial with 'Invoke Application'. The Phase 'Render Response' is too late if you are using c:if to skip components from the component tree. See attached example app and pictures.
        Hide
        Bernd Bohmann added a comment - - edited

        In the late-render-expression-4.png it should also update the first test output and render 'test: 2'. Only the region with the c:if inside was updated.

        Show
        Bernd Bohmann added a comment - - edited In the late-render-expression-4.png it should also update the first test output and render 'test: 2'. Only the region with the c:if inside was updated.
        Bernd Bohmann made changes -
        Attachment late-render-expression.tgz [ 12526113 ]
        Attachment late-render-expression-0.png [ 12526114 ]
        Attachment late-render-expression-1.png [ 12526115 ]
        Attachment late-render-expression-2.png [ 12526116 ]
        Attachment late-render-expression-3.png [ 12526117 ]
        Attachment late-render-expression-4.png [ 12526118 ]
        Hide
        Leonardo Uribe added a comment -

        This is an interesting piece of code. I'll describe what I can see, I know you already know this but I'm just trying to follow the steps.

        In theory, org.apache.myfaces.renderkit.html.HtmlAjaxBehaviorRenderer look for the components, get its clientIds, and finally pass them as params when writing the js code related to the ajax operation.

        In this case, the values passed in "javax.faces.partial.render" request parameter, which are the same that were calculated before are just ignored, and the values used for identify the affected client behavior, which are used in the decode process (see org.apache.myfaces.shared.renderkit.html.HtmlRendererUtils.decodeClientBehaviors() ), are used to calculate the affected components, but the good part is if you use c:if to skip components from the component tree, they will not be used.

        There is not any reference in the spec about this. "In theory", include it will not cause any side effects more than solve the problem described here. The only thing that suppose a problem is this propose a different behavior from the one found in the RI (Mojarra), maybe not thought by the EG when the spec was built.

        I don't know what to do in this case. A custom <f:ajax> component with this behavior in mind sounds better for me than change the default behavior. Any thoughts?

        Show
        Leonardo Uribe added a comment - This is an interesting piece of code. I'll describe what I can see, I know you already know this but I'm just trying to follow the steps. In theory, org.apache.myfaces.renderkit.html.HtmlAjaxBehaviorRenderer look for the components, get its clientIds, and finally pass them as params when writing the js code related to the ajax operation. In this case, the values passed in "javax.faces.partial.render" request parameter, which are the same that were calculated before are just ignored, and the values used for identify the affected client behavior, which are used in the decode process (see org.apache.myfaces.shared.renderkit.html.HtmlRendererUtils.decodeClientBehaviors() ), are used to calculate the affected components, but the good part is if you use c:if to skip components from the component tree, they will not be used. There is not any reference in the spec about this. "In theory", include it will not cause any side effects more than solve the problem described here. The only thing that suppose a problem is this propose a different behavior from the one found in the RI (Mojarra), maybe not thought by the EG when the spec was built. I don't know what to do in this case. A custom <f:ajax> component with this behavior in mind sounds better for me than change the default behavior. Any thoughts?
        Hide
        Dora Rajappan added a comment -

        The spec has given preference to c:if over ajax and can be corrected otherwise it will defeat the purpose of ajax.

        Show
        Dora Rajappan added a comment - The spec has given preference to c:if over ajax and can be corrected otherwise it will defeat the purpose of ajax.
        Hide
        Dora Rajappan added a comment -

        This problem may be solved now with the new visit algorithm. Leonardo responded before this change. I will check the problem is still there with current jsf 2.2.

        Show
        Dora Rajappan added a comment - This problem may be solved now with the new visit algorithm. Leonardo responded before this change. I will check the problem is still there with current jsf 2.2.
        Hide
        Leonardo Uribe added a comment -

        It is not solved in JSF 2.2 spec. The spec is silent in this regard. I still believe this should be discussed on the EG before do anything. Maybe this is something for 2.3.

        Show
        Leonardo Uribe added a comment - It is not solved in JSF 2.2 spec. The spec is silent in this regard. I still believe this should be discussed on the EG before do anything. Maybe this is something for 2.3.
        Hide
        Dora Rajappan added a comment -

        This particular behaviour of evaluating the render ids on the fly and then rendering those ids is not something the spec thought of implementing.

        Show
        Dora Rajappan added a comment - This particular behaviour of evaluating the render ids on the fly and then rendering those ids is not something the spec thought of implementing.
        Hide
        Dora Rajappan added a comment -

        There is no problem with c:if component behaviour with visit algorithm also. Info2 component is in execute and when the checkbox was deselected subsequent ajax request test2 got skipped which is expected. If info2 is removed from execute ajax render wont skip test2 . Preference is clearly for ajax. I misunderstood the problem was with skipping components and not purely for late value expression evaluation for render attribute.

        Show
        Dora Rajappan added a comment - There is no problem with c:if component behaviour with visit algorithm also. Info2 component is in execute and when the checkbox was deselected subsequent ajax request test2 got skipped which is expected. If info2 is removed from execute ajax render wont skip test2 . Preference is clearly for ajax. I misunderstood the problem was with skipping components and not purely for late value expression evaluation for render attribute.
        Dora Rajappan made changes -
        Status Open [ 1 ] Patch Available [ 10002 ]
        Hide
        Dora Rajappan added a comment -

        The fix provided is good. Its also good to support late value render.

        Show
        Dora Rajappan added a comment - The fix provided is good. Its also good to support late value render.
        Dora Rajappan made changes -
        Attachment laterender.patch [ 12610317 ]

          People

          • Assignee:
            Unassigned
            Reporter:
            Bernd Bohmann
          • Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:

              Development