Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.2
    • Fix Version/s: 1.0
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      71

      Description

      See: https://javaserverfaces.dev.java.net/issues/show_bug.cgi?id=10

      There is still the following outstanding issue related to onclick:

      One thing I could suggest in for areas where we generate Javascript in
      CommandLinkRenderer, if the attribute already has a value, prepend our script to
      the existing value. I'm not sure if the renderkits already works that way?

      onClick="alert('Developer debugging');"

      becomes

      onClick="injectedScript(); alert('Developer debugging');"

      Adam's response:
      The tricky thing is making sure that you preserve semantics
      of their callback, especially w.r.t to the return value.
      This commandButton case is actually fairly straightforward here;
      prepending this script would work fine. But commandLink
      would be trickier, since you'd really want to prepend the user's
      script, and only call the built-in onclick if the user's
      script does not return false. This takes some fancy footwork
      in Javascript.

      The following code would allow injection of JSF code next to the User code no
      matter if they defined a return type or not.

      var a=function()

      {#USER_FUNCTION#}

      ;
      var b=function()

      {#JSF_FUNCTION#}

      ;
      return (a()==false) ? false : b();

        Activity

        Hide
        rogerk added a comment -

        Attaching another change bundle with test cases. These changes are being
        incorporated from Jacob Hookum. Thanks Jacob!

        SECTION: Modified Files
        ----------------------------
        M jsf-api/doc/standard-html-renderkit-base.xml

        • re-enable "onclick" for LinkRenderer
          M jsf-api/doc/standard-html-renderkit.xml
        • generated
          M jsf-ri/src/com/sun/faces/renderkit/html_basic/CommandLinkRenderer.java
        • The renderer will now check to see if a user specified the 'onClick' attribute
          on the CommandLink component. If the onClick was specified by the user, then
          wrap the user's Javascript and the injected Javascript in a choice function.
          The result is if the user code returns false, then the injected code will not
          run. User code that doesn't return false will execute, then the injected code
          will execute.

        var a=function()

        {#USER_FUNCTION#}

        ;
        var b=function()

        {#JSF_FUNCTION#}

        ;
        return (a()==false) ? false : b();

        A jsf-ri/systest/src/com/sun/faces/jsptest/CommandLinkOnClickTestCase.java
        A jsf-ri/systest/web/jsp/commandLinkOnClickFalse.jsp
        A jsf-ri/systest/web/jsp/commandLinkOnClickTrue.jsp

        • test cases
        Show
        rogerk added a comment - Attaching another change bundle with test cases. These changes are being incorporated from Jacob Hookum. Thanks Jacob! SECTION: Modified Files ---------------------------- M jsf-api/doc/standard-html-renderkit-base.xml re-enable "onclick" for LinkRenderer M jsf-api/doc/standard-html-renderkit.xml generated M jsf-ri/src/com/sun/faces/renderkit/html_basic/CommandLinkRenderer.java The renderer will now check to see if a user specified the 'onClick' attribute on the CommandLink component. If the onClick was specified by the user, then wrap the user's Javascript and the injected Javascript in a choice function. The result is if the user code returns false, then the injected code will not run. User code that doesn't return false will execute, then the injected code will execute. var a=function() {#USER_FUNCTION#} ; var b=function() {#JSF_FUNCTION#} ; return (a()==false) ? false : b(); A jsf-ri/systest/src/com/sun/faces/jsptest/CommandLinkOnClickTestCase.java A jsf-ri/systest/web/jsp/commandLinkOnClickFalse.jsp A jsf-ri/systest/web/jsp/commandLinkOnClickTrue.jsp test cases
        Hide
        rogerk added a comment -

        Created an attachment (id=59)
        Change budle for this issue.

        Show
        rogerk added a comment - Created an attachment (id=59) Change budle for this issue.
        Hide
        jayashri added a comment -

        r=jayashri

        Show
        jayashri added a comment - r=jayashri
        Hide
        rogerk added a comment -

        Jacob's mods and Roger's test cases checked in.

        Show
        rogerk added a comment - Jacob's mods and Roger's test cases checked in.
        Hide
        Manfred Riem added a comment -

        Closing issue out

        Show
        Manfred Riem added a comment - Closing issue out

          People

          • Assignee:
            jhook
            Reporter:
            jhook
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: