Re: AbstractDefaultAjaxBehavior target does not refresh components

2014-09-08 Thread Martin Grigorov
Hi,

You should use Wicket.Ajax.post() instead of jQuery.ajax() to make Ajax
call. Otherwise Wicket won't be able to calculate the baseUrl and all urls
created in this request cycle would be wrong.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov


On Mon, Sep 8, 2014 at 4:47 PM, alexena  wrote:

> 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
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/AbstractDefaultAjaxBehavior-target-does-not-refresh-components-tp4667379.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


AbstractDefaultAjaxBehavior target does not refresh components

2014-09-08 Thread alexena
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

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/AbstractDefaultAjaxBehavior-target-does-not-refresh-components-tp4667379.html
Sent from the Users forum mailing list archive at Nabble.com.

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