You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Mihai Toma <mi...@asf.ro> on 2012/05/07 14:47:24 UTC

refresh page from an AjaxLink or OnChangeAjaxBehavior

Hi,

 

I have an OnChangeAjaxBehavior on a DropDownChoice component.

 

After I change a value in that drop down I want to reload the page using
setResponse(currentPage.getClass(), currentPage.getPageParameters());

 

themeComp.add(new OnChangeAjaxBehavior() {

                                                private static final long
serialVersionUID = -1973825163343103968L;

 

                                                @Override

                                                protected void
onUpdate(final AjaxRequestTarget arg0) {

 
setAValueInSession();

setResponse(currentPage.getClass(), currentPage.getPageParameters());

                                                }

                                });

 

The response from ajax debug is "ERROR: Wicket.Ajax.Call.failure: Error
while parsing response: Could not find root <ajax-response> element". I
receive the content from ajax but it is not between <ajax-response> element.

 

I verify this problem on AjaxLink and the response is the same as from
OnChangeAjaxBehavior.

 

Do you have any idea how to reload the page from an AjaxLink or
OnChangeAjaxBehavior ?

 

Thanks,

Mihai


Re: refresh page from an AjaxLink or OnChangeAjaxBehavior

Posted by jensiator <je...@gmail.com>.
Do you really need to call this?
setResponse(currentPage.getClass(), currentPage.getPageParameters()); 

If its just some components on the same page that will be affected by the
dropdown change, the above solution feels unnecessary. If you use ajax or
javascript the page don't need to be updated in a ordinary. request 

You could just update the component/components on the page that my be
affected by the dropdown change. You can do this by adding these components
to the AjaxRequestTarget.
If you add a AjaxFormComponentUpdatingBehavior on the dropdown, and a model
to the page, you would even update the model with the dropdown value. Any
components that you have added to the AjaxRequestTarget would then render.
In these affected components you can either override onComponentTag or
--TagBody to change it rendered values. I prefer to give the components a
specialized model. 
in wicket 1.5 you can do it even decoupled. 

If I not completely off target I can give you some code examples..



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/refresh-page-from-an-AjaxLink-or-OnChangeAjaxBehavior-tp4614698p4623193.html
Sent from the Users forum mailing list archive at Nabble.com.

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


RE: refresh page from an AjaxLink or OnChangeAjaxBehavior

Posted by Mihai Toma <mi...@asf.ro>.
Forgot to say wicket 1.5.5.

Mihai

-----Original Message-----
From: Mihai Toma [mailto:mihai.toma@asf.ro] 
Sent: Monday, May 07, 2012 3:47 PM
To: users@wicket.apache.org
Subject: refresh page from an AjaxLink or OnChangeAjaxBehavior

Hi,

 

I have an OnChangeAjaxBehavior on a DropDownChoice component.

 

After I change a value in that drop down I want to reload the page using
setResponse(currentPage.getClass(), currentPage.getPageParameters());

 

themeComp.add(new OnChangeAjaxBehavior() {

                                                private static final long
serialVersionUID = -1973825163343103968L;

 

                                                @Override

                                                protected void
onUpdate(final AjaxRequestTarget arg0) {

 
setAValueInSession();

setResponse(currentPage.getClass(), currentPage.getPageParameters());

                                                }

                                });

 

The response from ajax debug is "ERROR: Wicket.Ajax.Call.failure: Error
while parsing response: Could not find root <ajax-response> element". I
receive the content from ajax but it is not between <ajax-response> element.

 

I verify this problem on AjaxLink and the response is the same as from
OnChangeAjaxBehavior.

 

Do you have any idea how to reload the page from an AjaxLink or
OnChangeAjaxBehavior ?

 

Thanks,

Mihai



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