After exploring a little further, I discovered the below thread on
invoking javascript from within Tapestry.

https://stackoverflow.com/questions/27988473/pass-parameter-from-java-to-js-in-tapestry

Joost writes:

You will need to use the JavaScriptSupport service.

Your java file:

@Import(library = "RoomManagement.js")
public final class RoomManagement{

  @Inject
  private JavaScriptSupport javascriptSupport;

  @Property
  private long contactId;

  @AfterRender
  private void setup() {
    JSONObject jsonObject = new JSONObject();
    jsonObject.put("contactId", contactId);
    javascriptSupport.addInitializerCall("RoomManagement",jsonObject);
  }
}

Your RoomManagement.js

Tapestry.Initializer.RoomManagement = function (parameters) {
    //do whatever you need here
    alert('Your contactId: ' + parameters.contactId);
};

This looks promising, but I later read that Tapestry's handling of
javascript has been completely rewritten in Tapestry 5.4, with the above
being deprecated.  And I've not found any example code of doing tnings the
new way.  Any pointers would be much appreciated.

My page contains 10 expand/collapse buttons, and I only wish to animate
the one connected to the zone being updated.  So am thinking of giving
each button a unique ID, and passing that ID to the javascript so just the
one button animates.

My needs are pretty straight forward, and reportedly Tapestry's javascript
handling was completely rewritten in 5.4 to simplify things.  Look forward
to seeing how things now get done.  :-)

Appreciate any help.

Regards,

Chris.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to