Tapestry
  1. Tapestry
  2. TAPESTRY-2266

Incorrect EventListener documentation for intercepting Javascript functions

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 4.1.5
    • Fix Version/s: 4.1.6
    • Component/s: Documentation
    • Labels:
      None
    • Environment:
      Any

      Description

      The documentation at http://tapestry.apache.org/tapestry4.1/ajax/eventlistener.html has an example for intercepting Javascript functions that uses both "targets" and "elements" arguments for the annotation, but the documentation for the annotation itself says you can only use either one or the other. Furthermore, it might make people better realize how much the annotation simplifies client/server communication and how endless the possibilities really are if you added something like this to the Javascript example:

      The required html/Javascript snippet:
      <div id="triggerable"></div>
      <script type="text/javascript">
      var triggerable = document.getElementById('triggerable');
      triggerable.trigger = function(params) {
        alert('calling server with answer ' + params.theAnswer);
      }
      </script>
      
      So, given a Javascript...
      @EventListener(events="trigger", elements="triggerable")
      public void onTriggered( BrowserEvent event ) {
      ...
      }
      

        Activity

        Hide
        Marcus Schulte added a comment -

        fixed, thanks for filing the issue.

        Show
        Marcus Schulte added a comment - fixed, thanks for filing the issue.
        Hide
        Jay Sellers added a comment -

        I know this is closed, but I'm trying to implement this exact example. I have no idea what the code should look like that actually calls "triggerable.trigger". The documentation says:

        So, given a javascript function "trigger" defined on component "triggerable" which was called like triggerable.trigger(

        {"theAnswer":42}

        , ... ), you may get hold of the answer like that:

        But I have no idea where "triggerable.trigger(

        {"theAnswer":42}

        , ... )" goes, can you update the documentation to contain a code snipit for this as well?

        Show
        Jay Sellers added a comment - I know this is closed, but I'm trying to implement this exact example. I have no idea what the code should look like that actually calls "triggerable.trigger". The documentation says: So, given a javascript function "trigger" defined on component "triggerable" which was called like triggerable.trigger( {"theAnswer":42} , ... ), you may get hold of the answer like that: But I have no idea where "triggerable.trigger( {"theAnswer":42} , ... )" goes, can you update the documentation to contain a code snipit for this as well?
        Hide
        Kalle Korhonen added a comment -

        JIRA is not a general discussion board. However, the code that calls triggerable.trigger() is yours, ie. put it where ever you like. The example was meant showcase that you can bind to listen to any client-side Javascript function invocation and get an server-side event triggered simply by adding the annotation.

        Show
        Kalle Korhonen added a comment - JIRA is not a general discussion board. However, the code that calls triggerable.trigger() is yours, ie. put it where ever you like. The example was meant showcase that you can bind to listen to any client-side Javascript function invocation and get an server-side event triggered simply by adding the annotation.
        Hide
        Jay Sellers added a comment -

        Where is the discussion board?
        I've got this to work, kind of. My service intercepted the call but I can't seem to manipulate any other class attributes inside the method. Aka I have a public abstract List getSites() method that I want to clear in the intercepted method but it doesn't seem to take effect.

        I understand what Jira is, feel free to delete my comments. I just couldn't fine this example referenced anywhere else and colleagues didn't know the answer.

        Show
        Jay Sellers added a comment - Where is the discussion board? I've got this to work, kind of. My service intercepted the call but I can't seem to manipulate any other class attributes inside the method. Aka I have a public abstract List getSites() method that I want to clear in the intercepted method but it doesn't seem to take effect. I understand what Jira is, feel free to delete my comments. I just couldn't fine this example referenced anywhere else and colleagues didn't know the answer.

          People

          • Assignee:
            Marcus Schulte
            Reporter:
            Kalle Korhonen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development