javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-63

Use of Browser's back-button causes multiple ActionEvents to pile up.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.1_01
    • Fix Version/s: 1.0
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      63

      Description

      I have an index page with a dataTable listing wedgets. each row of the table contains a commandLink
      to load action that displays an editor screen allowing the user to edit the loaded widget. in the footer
      of the data table I have a commandButton linking to a create action that displays a page allowing the
      user to create a new widget.

      if the user clicks on widget 1 and correctly gets the edit screen for that widget, then clicks the back
      button and then clicks the 'new widget' commandButton then during the INVOKE_APPLICATION phase
      both the create and then the load actionEvents are fired with the consequence that the details of the
      previously loaded widget appear in the creation screen.

      I have added a bunch of debugs to various bits of the api code to get a better idea of what is going on.
      I have also tried patching my JSF code base (grabbed from CVS) with the patch suggested by issue#28
      but none of that has made any difference.

      If I swap out the Ri and swap in MyFaces then the problem is resolved - but new problems emerge (alas)

      my logging looks like this:
      16:50:40,134 DEBUG PhaseTracker:86 - beforePhase PhaseId: 'INVOKE_APPLICATION 5', ViewRoot id =
      '/handler/index.jsp'
      16:50:40,136 DEBUG UIViewRoot:233 - about to broadcast events for phase 'INVOKE_APPLICATION 5'.
      16:50:40,137 DEBUG UIComponentBase:644 - begin broadcasting event
      javax.faces.event.ActionEvent[source=javax.faces.component.html.HtmlCommandButton@a2a3c7] for
      component id = new_widget
      16:50:40,139 DEBUG UIComponentBase:651 - no listeners - end event broadcast.
      16:50:40,141 DEBUG ActionListenerImpl:? - processAction(new_widget)
      16:50:40,142 DEBUG AbstractHandler:145 - create()
      16:50:40,145 DEBUG AbstractHandler:212 - clear()
      16:50:40,147 DEBUG WidgetHandler:94 - instantiateItem()
      16:50:40,148 DEBUG WidgetHandler:173 - modelToView()
      16:50:40,150 DEBUG ViewHandlerImpl:? - Created new view for /handler/new_widget.faces
      16:50:40,151 DEBUG ViewHandlerImpl:? - Using locale from previous view en
      16:50:40,153 DEBUG ViewHandlerImpl:? - Using renderKitId from previous view HTML_BASIC
      16:50:40,154 DEBUG NavigationHandlerImpl:? - Set new view in FacesContext for /handler/
      new_widget.faces
      16:50:40,155 DEBUG UIComponentBase:644 - begin broadcasting event
      javax.faces.event.ActionEvent[source=javax.faces.component.html.HtmlCommandLink@381488] for
      component id = edit_widget
      16:50:40,157 DEBUG UIComponentBase:651 - no listeners - end event broadcast.
      16:50:40,158 DEBUG ActionListenerImpl:? - processAction(edit_widget)
      16:50:40,160 DEBUG AbstractHandler:163 - load()
      16:50:40,161 DEBUG AbstractHandler:212 - clear()
      16:50:40,163 DEBUG WidgetHandler:81 - loadById(1)
      16:50:40,164 DEBUG WidgetHandler:173 - modelToView()
      16:50:40,166 DEBUG ViewHandlerImpl:? - Created new view for /handler/edit_widget.faces
      16:50:40,167 DEBUG ViewHandlerImpl:? - Using locale from previous view en
      16:50:40,169 DEBUG ViewHandlerImpl:? - Using renderKitId from previous view HTML_BASIC
      16:50:40,170 DEBUG NavigationHandlerImpl:? - Set new view in FacesContext for /handler/
      edit_widget.faces
      16:50:40,172 DEBUG UIViewRoot:304 - ended broadcast of events for phase INVOKE_APPLICATION 5
      16:50:40,174 DEBUG PhaseTracker:94 - afterPhase PhaseId: 'INVOKE_APPLICATION 5', ViewRoot id = '/
      handler/edit_widget.faces'

      you can see clearly that the old event is being fired aafter the correct event.

      help! this is a total showstopper for us as our users always use their browser back buttons.

        Activity

        Hide
        jayashri added a comment -

        Created an attachment (id=53)
        Fix for JSF RI 63

        Show
        jayashri added a comment - Created an attachment (id=53) Fix for JSF RI 63
        Hide
        Ed Burns added a comment -

        r=edburns

        Show
        Ed Burns added a comment - r=edburns
        Hide
        jayashri added a comment -

        M jsf-ri/src/com/sun/faces/renderkit/html_basic/FormRenderer.java
        Generated javascript should only clear out the hidden fields rendered by the f
        orm.

        Index: jsf-ri/src/com/sun/faces/renderkit/html_basic/FormRenderer.java
        ===================================================================
        RCS file:
        /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/renderkit/html_basic/FormRenderer.java,v
        retrieving revision 1.82
        diff -u -r1.82 FormRenderer.java
        — jsf-ri/src/com/sun/faces/renderkit/html_basic/FormRenderer.java 16 Dec 2004
        17:56:37 -0000 1.82
        +++ jsf-ri/src/com/sun/faces/renderkit/html_basic/FormRenderer.java 10 Mar 2005
        18:33:20 -0000
        @@ -300,11 +300,16 @@
        writer.write("(curFormName) {");
        writer.write("\n var curForm = document.forms[curFormName];");
        if (formParams != null) {

        • for (Iterator it = formParams.keySet().iterator(); it.hasNext() { - writer.write("\n curForm.elements['"); - writer.write((String)it.next()); - writer.write("'].value = null;"); - }

          + Iterator entries = formParams.entrySet().iterator();
          + // clear only the hidden fields rendered by the form.
          + while (entries.hasNext())

          Unknown macro: {+ Map.Entry entry = (Map.Entry) entries.next();+ if (Boolean.TRUE.equals(entry.getValue())) { + writer.write("\n curForm.elements['"); + writer.write((String) entry.getKey()); + writer.write("'].value = null;"); + }+ }

          }
          // clear form target attribute if its present
          if (formTarget != null && formTarget.length() > 0) {

        Show
        jayashri added a comment - M jsf-ri/src/com/sun/faces/renderkit/html_basic/FormRenderer.java Generated javascript should only clear out the hidden fields rendered by the f orm. Index: jsf-ri/src/com/sun/faces/renderkit/html_basic/FormRenderer.java =================================================================== RCS file: /cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/renderkit/html_basic/FormRenderer.java,v retrieving revision 1.82 diff -u -r1.82 FormRenderer.java — jsf-ri/src/com/sun/faces/renderkit/html_basic/FormRenderer.java 16 Dec 2004 17:56:37 -0000 1.82 +++ jsf-ri/src/com/sun/faces/renderkit/html_basic/FormRenderer.java 10 Mar 2005 18:33:20 -0000 @@ -300,11 +300,16 @@ writer.write("(curFormName) {"); writer.write("\n var curForm = document.forms [curFormName] ;"); if (formParams != null) { for (Iterator it = formParams.keySet().iterator(); it.hasNext() { - writer.write("\n curForm.elements['"); - writer.write((String)it.next()); - writer.write("'].value = null;"); - } + Iterator entries = formParams.entrySet().iterator(); + // clear only the hidden fields rendered by the form. + while (entries.hasNext()) Unknown macro: {+ Map.Entry entry = (Map.Entry) entries.next();+ if (Boolean.TRUE.equals(entry.getValue())) { + writer.write("\n curForm.elements['"); + writer.write((String) entry.getKey()); + writer.write("'].value = null;"); + }+ } } // clear form target attribute if its present if (formTarget != null && formTarget.length() > 0) {
        Hide
        jayashri added a comment -

        Fix checked in.

        Show
        jayashri added a comment - Fix checked in.
        Hide
        Manfred Riem added a comment -

        Closing issue out

        Show
        Manfred Riem added a comment - Closing issue out

          People

          • Assignee:
            jayashri
            Reporter:
            davesag
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: