I'm trying to create a custom implementation of bootstrap/modal where I can
dynamically load the content via ajax while modal is open. My use case is
iterate through a series of warnings while clicking the submit action. I'd
like to dynamically inject those warnings via ajax, however I do not know
how to write a custom ajax request in tapestry.
What I think I know,
I'm assuming I need to create an event link and pass it into my js like so
and then setup a jquery ajax request. I do not know how to properly set up
the request so that it returns a response.
In my little demo below, I'd like to try and update the title with an ajax
request to tapestry's backend.
public class AjaxDemo {
static final String EVENT_NAME = "ajaxdemo";
@Parameter(required = true)
private String clientId;
void afterRender() {
Link link = resources.createEventLink(EVENT_NAME);
JSONObject spec = new JSONObject("id" ,clientId, "url",
link.toString());
jsSupport.require("ajaxDemo").with(spec);
AjaxDemo.js
define(["jquery"], function($) {
int = function(spec) {
var title= $( "h2" ).attr("id", spec.clientId);
$("body").append(title);
//Action to update title however I do not know how to return a
response nor am I sure if I ned to pass other params back.
$("button").bind("click", function() {
$.ajax({
url: spec.url
});
});
return int;
});
Tapestry Page.
public class Demo {
// I completely do not understand how to return a response without the
use of a tapestry zone.
Object onAjaxDemo() {
return "Updated Title";
If there is documentation or examples on how to do this, please feel free
to share them with me, otherwise I'd really appreciate anybody who has the
time to finish the above example and explain what I'm missing. This kind of
example might work well with Geoff's jumpstart.
Thanks,
George
dynamically load the content via ajax while modal is open. My use case is
iterate through a series of warnings while clicking the submit action. I'd
like to dynamically inject those warnings via ajax, however I do not know
how to write a custom ajax request in tapestry.
What I think I know,
I'm assuming I need to create an event link and pass it into my js like so
and then setup a jquery ajax request. I do not know how to properly set up
the request so that it returns a response.
In my little demo below, I'd like to try and update the title with an ajax
request to tapestry's backend.
public class AjaxDemo {
static final String EVENT_NAME = "ajaxdemo";
@Parameter(required = true)
private String clientId;
void afterRender() {
Link link = resources.createEventLink(EVENT_NAME);
JSONObject spec = new JSONObject("id" ,clientId, "url",
link.toString());
jsSupport.require("ajaxDemo").with(spec);
AjaxDemo.js
define(["jquery"], function($) {
int = function(spec) {
var title= $( "h2" ).attr("id", spec.clientId);
$("body").append(title);
//Action to update title however I do not know how to return a
response nor am I sure if I ned to pass other params back.
$("button").bind("click", function() {
$.ajax({
url: spec.url
});
});
return int;
});
Tapestry Page.
public class Demo {
// I completely do not understand how to return a response without the
use of a tapestry zone.
Object onAjaxDemo() {
return "Updated Title";
If there is documentation or examples on how to do this, please feel free
to share them with me, otherwise I'd really appreciate anybody who has the
time to finish the above example and explain what I'm missing. This kind of
example might work well with Geoff's jumpstart.
Thanks,
George