Uploaded image for project: 'Tapestry'
  1. Tapestry
  2. TAPESTRY-1132

EventListeners can not be wired up programatically ( needed to handle For loops)

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • 4.2
    • None
    • None

    Description

      What I am hoping to do is something like this:

      <span jwcid="@For" value="ognl:current">
      <a jwcid="foo"><span jwcid="@Insert" value="ognl:current"/></a>
      <span jwcid="@InvokeListener" listener="listener:makeLink"/>
      </span>

      and code like this:

      public void makeLink() {
      IEventListener listener = getFoo().getEventListener("onclick");
      listener.setEventHandler("bar");
      listener.setParameters(new Object[]

      { getCurrent().getEntityId()}

      );
      }

      // called when user clicks on one of the generated links in @For
      public void bar(Long entityId)

      { System.out.println("link for "+ entityId +"was clicked!"); }

      Hope that helps...

      CD suggested this:

      I found a nice solution using dojo's ability to listen to an arbitrary
      javascript function as if it were a native event.
      I attach an empty js function to an arbitrary DOM element like this:

      document.getElementById('someDiv').clickRadio=function(radio) {};

      and an onclick attribute to my radio buttons:

      <span jwcid="@Radio" value="ognl:lv.value" onclick="document.getElementById
      ('someDiv').clickRadio(this);"/>

      Then I can set an EventListener on the server-side

      @EventListener(targets = "someDiv", events = "clickRadio", submitForm =
      "form")
      public void listenToOnclickOnAnyRadioButtonInTheForLoop(IRequestCycle
      cycle) throws InterruptedException

      { ... }

      Works fine.
      Ch.

      Attachments

        Activity

          People

            Unassigned Unassigned
            patmoore@ieee.org Patrick Moore
            Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: