MyFaces Core
  1. MyFaces Core
  2. MYFACES-1276

Add new methods to HtmlFormBaseRenderer to ease integration support with AjaxAnywhere

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1.1
    • Fix Version/s: 1.1.3
    • Component/s: None
    • Labels:
      None

      Description

      One method of implementing AJAX is to re-render the page and only send
      pieces down to the browser. This is the way AjaxAnywhere works.
      However, it is not easy to get this to work in MyFaces with HTML
      forms. The issue:

      AJAX needs a way to identify HTML to replace on AJAX response. This is
      usually done via id:
      "document.getElementById('idFromAjaxResponse').innerHtml =
      reponseData".

      However, there is no containing HTML element for the "special" form
      elements. These "special" elements include:

      1) input type="hidden" elements that are rendered for parameters,
      client-side state, etc.
      2) script tag that contains the clear_[formid]() JavaScript function
      that uses the above hidden input elements

      In 1.1.1, these were placed at the top and bottom of the form. In
      1.1.2/3 they are put only at the bottom, but in neither is the
      capability that I would like.

      Workaround I used: Extended the HtmlFormRenderer and buffered the
      output of the endcodeEnd and encodeBegin. Then I loop through the
      buffer and strip out all hidden input elements and JavaScript tags. I
      then add the stripped portion into a new SPAN element that is
      formatted for AjaxAnywhere to work.

      How this could have been much easier:

      Add 4 new methods to HtmlFormRendererBase:
      public void beforeFormElementsStart(FacesContext facesContext,
      UIComponent component)
      throws IOException {}
      public void afterFormElementsStart(FacesContext facesContext,
      UIComponent component)
      throws IOException {}
      public void beforeFormElementsEnd(FacesContext facesContext,
      UIComponent component)
      throws IOException {}
      public void afterFormElementsEnd(FacesContext facesContext,
      UIComponent component)
      throws IOException {}

      These methods would the be called:
      encodeBegin(...) {
      ...render the start tag...
      call before form elements start
      ...render and elements into the form
      call after form elements end

      ...

      encodeEnd(...) {
      call before form elements end
      ... render state, javascript etc. ...
      call after form elements end
      ... render the form end tag ...

      Then, with projects like AjaxAnywhere, users can extend
      HtmlFormRenderer and implement these methods. In these methods, we can
      write tags to contain this data that can be used in the AJAX code to
      update on every request.

      This would be a very simple change, would incur almost no overhead and
      give complete flexibility that would be needed to AJAX authors to have
      control over the special form behavior of JSF.

      I wouldn't care about the method names, in fact there could be one
      method with an enum argument that specifies before/after information.

      1. myfaces-1.1.1-jira-1276.diff
        2 kB
        Andrew Robinson
      2. myfaces-1.1.3-jira-1276.diff
        3 kB
        Andrew Robinson

        Activity

        Andrew Robinson created issue -
        Andrew Robinson made changes -
        Field Original Value New Value
        Status Open [ 1 ] Patch Available [ 10002 ]
        Hide
        Andrew Robinson added a comment -

        Patch for the 1.1.1 version of the base renderer for this issue.

        Show
        Andrew Robinson added a comment - Patch for the 1.1.1 version of the base renderer for this issue.
        Andrew Robinson made changes -
        Attachment myfaces-1.1.1-jira-1276.diff [ 12325141 ]
        Hide
        Andrew Robinson added a comment -

        Patch to the current SVN version (1.1.3?) to support this functionality. (patch from the share directory of SVN)

        Show
        Andrew Robinson added a comment - Patch to the current SVN version (1.1.3?) to support this functionality. (patch from the share directory of SVN)
        Andrew Robinson made changes -
        Attachment myfaces-1.1.3-jira-1276.diff [ 12325142 ]
        sean schofield made changes -
        Workflow MyFaces Workflow [ 12354985 ] MyFaces Workflow2 [ 12355349 ]
        sean schofield made changes -
        Workflow MyFaces Workflow2 [ 12355349 ]  MyFaces Workflow [ 12356879 ]
        sean schofield made changes -
        Fix Version/s 1.1.3-SNAPSHOT [ 12310852 ]
        Fix Version/s 1.1.1 [ 12310262 ]
        sean schofield made changes -
        Workflow  MyFaces Workflow [ 12356879 ] MyFaces Workflow2 [ 12360830 ]
        Hide
        Mike Kienenberger added a comment -

        Committed. I'm fairly certain that this won't cause a TCK issue, but if it does, we'll have to pull it back out.

        Show
        Mike Kienenberger added a comment - Committed. I'm fairly certain that this won't cause a TCK issue, but if it does, we'll have to pull it back out.
        Mike Kienenberger made changes -
        Assignee Mike Kienenberger [ mkienenb ]
        Resolution Fixed [ 1 ]
        Fix Version/s 1.1.3-SNAPSHOT [ 12310852 ]
        Status Patch Available [ 10002 ] Closed [ 6 ]
        sean schofield made changes -
        Fix Version/s 1.1.3-SNAPSHOT [ 12310852 ]
        Fix Version/s 1.1.3 [ 12311042 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Patch Available Patch Available
        21s 1 Andrew Robinson 11/Apr/06 00:24
        Patch Available Patch Available Closed Closed
        10d 23h 53m 1 Mike Kienenberger 22/Apr/06 00:18

          People

          • Assignee:
            Mike Kienenberger
            Reporter:
            Andrew Robinson
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development