Hi everyone,
I have a problem with AbstractDefaultAjaxBehavior on receiving POST request
sent by client side. Target on respond method does not seem to work - it
process post request but target.add(component) does not refresh a component
in parameter.
What I'm trying to do is process post request witch contains a set of search
fields written by user. Then, I translate a received json into SQL request
and then I update the ListView to show the results of user request.
In my js I have:
$.ajax({
url : callbackUrl2,
type : 'POST',
cache : false,
dataType : 'json',
data: JSON.stringify(valuesArray),
contentType: "application/json; charset=utf-8",
success: function(data) {
console.log(data);
});
and on the server side I have:
this.ajaxbeh2 = new AbstractDefaultAjaxBehavior() {
/**
*/
private static final long serialVersionUID = 1L;
@Override
public void renderHead(final Component component,
final IHeaderResponse response) {
super.renderHead(component, response);
response.render(JavaScriptHeaderItem.forScript(
"var callbackUrl2 = '" + this.getCallbackUrl() + "';",
"callbackurl2"));
@Override
protected void respond(final AjaxRequestTarget target) {
// some code to process json sent by post request
// this part has no effect on the application
SearchPage.this.pageLabelLabel
.setDefaultModelObject("Search Results");
target.add(SearchPage.this.pageLabelLabel);
target.add(SearchPage.this.pageLabelLabel);
SearchPage.this.patientsListView
.setList(SearchPage.this.patientsList);
target.add(patiensContainer);
target.addChildren(SearchPage.this.patientsListView,
Label.class);
Do you have an idea why target is ignoring in this code?
Thanks for your help,
Alex
I have a problem with AbstractDefaultAjaxBehavior on receiving POST request
sent by client side. Target on respond method does not seem to work - it
process post request but target.add(component) does not refresh a component
in parameter.
What I'm trying to do is process post request witch contains a set of search
fields written by user. Then, I translate a received json into SQL request
and then I update the ListView to show the results of user request.
In my js I have:
$.ajax({
url : callbackUrl2,
type : 'POST',
cache : false,
dataType : 'json',
data: JSON.stringify(valuesArray),
contentType: "application/json; charset=utf-8",
success: function(data) {
console.log(data);
});
and on the server side I have:
this.ajaxbeh2 = new AbstractDefaultAjaxBehavior() {
/**
*/
private static final long serialVersionUID = 1L;
@Override
public void renderHead(final Component component,
final IHeaderResponse response) {
super.renderHead(component, response);
response.render(JavaScriptHeaderItem.forScript(
"var callbackUrl2 = '" + this.getCallbackUrl() + "';",
"callbackurl2"));
@Override
protected void respond(final AjaxRequestTarget target) {
// some code to process json sent by post request
// this part has no effect on the application
SearchPage.this.pageLabelLabel
.setDefaultModelObject("Search Results");
target.add(SearchPage.this.pageLabelLabel);
target.add(SearchPage.this.pageLabelLabel);
SearchPage.this.patientsListView
.setList(SearchPage.this.patientsList);
target.add(patiensContainer);
target.addChildren(SearchPage.this.patientsListView,
Label.class);
Do you have an idea why target is ignoring in this code?
Thanks for your help,
Alex