You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by asarpe <as...@gmail.com> on 2010/07/12 14:57:59 UTC

Consecutive AJAX operations lead to Page Expired

Hello all,

I recently encountered a problem where two consecutive AJAX requests from
inside a panel, lead to a Page Expired exception.

More detailed:

The panel Panel contains a form Form and a ListView LW. Form has an
AjaxButton who's onSubmit method is implemented to add the content of the
Form to the DataBase(no errors here) and then update the LW via the button's
AjaxRequestTarget.
Everything works just fine the first time. The data ends up in the DataBase,
the LW is updated via AJAX and gets a new row. 
However if we repeat the operation and try adding a second row to the LW,
using the same steps, we get the PageExpiredErrorPage.

Any and all ideas are welcomed.
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Consecutive-AJAX-operations-lead-to-Page-Expired-tp2286087p2286087.html
Sent from the Wicket - User 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: Consecutive AJAX operations lead to Page Expired

Posted by Martin Grigorov <mc...@e-card.bg>.
I guess he meant that this is very common use case and that's why we
believe it is an error in your code.
Please create as simple as possible application that manifests the
problem [1] and attach it to a ticket in the bug tracking system [2].

[1] To create a simple application you may use Wicket Quickstart -
http://wicket.apache.org/quickstart.html
Extend it so it shows the problem.

[2] https://issues.apache.org/jira/browse/WICKET
You have to login to create a new ticket

On Tue, 2010-07-13 at 00:07 -0700, asarpe wrote:
> Not very sure what you meant by "quickstart or it didnt happen " but I am
> assuming is referring to the lack of code sample. If so, sorry for the
> incomplete post.
> 
> Here is the Panel class in question, trimmed down to size to just the
> relevant parts.
> 
> public class MyPanel extends Panel {
> 
> 	public MyPanel (String id, BasePage<?> parent) {
> 		super(id, parent);
> 		addPanelComponents();
> 	}
> 
> 	private class MyForm extends Form {
> 		private PageParameters properties;		
> 		public AddCompetitorForm(String name) {
> 			super(name);
> 			addFormComponents();
> 		}
> 
> 		public void addFormComponents() {
> 			this.properties = new PageParameters();
> 			add(new MyUrlTextField(WICKETID_INPUT, new
> PropertyModel<String>(this.properties, WICKETID_INPUT)));
> 			add(new AjaxButton(WICKETID_BUTTON_ADD, this) {
> 				protected void onError(AjaxRequestTarget target, Form<?> form) {
> 					super.onError(target, form);
> 					onApplicationError(target);
> 				}
> 				protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
> 					
> 					String value =
> AddCompetitorForm.this.properties.getString(WICKETID_INPUT);
> 						try {
> 							//write data to DB
>    							repaintListViewComponent(listView, listViewData, target,
> repaintableContainer);							
> 						} catch (Exception e) {
> 							onApplicationError(target, e, e.getMessage());
> 						}
> 				}
> 			});
> 		}
> 	}	
> 	
> 	protected void addPanelComponents() {
> 		add(new MyForm(WICKETID_FORM));
> 		listView = new ListView<WebsiteModel>(WICKETID_REPEATER, listViewData) {
> 			protected void populateItem(ListItem<MyPOJO> item) {
> 				final MyPOJO c = item.getModelObject();
> 
> 				item.add(new AjaxFallbackLink(WICKETID_BUTTON_DEL) {
> 					public void onClick(AjaxRequestTarget target) {
> 							try {
> 							//delete this entry from the database	
> 							listViewData.remove(c);
> 							repaintListViewComponent(listView, listViewData, target,
> repaintableContainer);
> 							} catch (Exception e) {
> 								onApplicationError(target, e, e.getMessage());
> 							}
> 						}
> 						getTimeLogger().endLoggingPage();
> 					}
> 				});
> 			}
> 		};
> 		listView.setReuseItems(true);
> 		listView.setOutputMarkupId(true);
> 		repaintableContainer.add(listView);
> 		add(repaintableContainer);
> 	}
> 		
> 	protected void repaintListViewComponent(ListView repeater, List model,
> AjaxRequestTarget target, WebMarkupContainer container) {
> 		repeater.modelChanging();
> 		repeater.removeAll();
> 		repeater.setList(model);
> 		repeater.modelChanged();		
> 		target.addComponent(container);
> 	}
> }
> 



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


Re: Consecutive AJAX operations lead to Page Expired

Posted by asarpe <as...@gmail.com>.
Not very sure what you meant by "quickstart or it didnt happen " but I am
assuming is referring to the lack of code sample. If so, sorry for the
incomplete post.

Here is the Panel class in question, trimmed down to size to just the
relevant parts.

public class MyPanel extends Panel {

	public MyPanel (String id, BasePage<?> parent) {
		super(id, parent);
		addPanelComponents();
	}

	private class MyForm extends Form {
		private PageParameters properties;		
		public AddCompetitorForm(String name) {
			super(name);
			addFormComponents();
		}

		public void addFormComponents() {
			this.properties = new PageParameters();
			add(new MyUrlTextField(WICKETID_INPUT, new
PropertyModel<String>(this.properties, WICKETID_INPUT)));
			add(new AjaxButton(WICKETID_BUTTON_ADD, this) {
				protected void onError(AjaxRequestTarget target, Form<?> form) {
					super.onError(target, form);
					onApplicationError(target);
				}
				protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
					
					String value =
AddCompetitorForm.this.properties.getString(WICKETID_INPUT);
						try {
							//write data to DB
   							repaintListViewComponent(listView, listViewData, target,
repaintableContainer);							
						} catch (Exception e) {
							onApplicationError(target, e, e.getMessage());
						}
				}
			});
		}
	}	
	
	protected void addPanelComponents() {
		add(new MyForm(WICKETID_FORM));
		listView = new ListView<WebsiteModel>(WICKETID_REPEATER, listViewData) {
			protected void populateItem(ListItem<MyPOJO> item) {
				final MyPOJO c = item.getModelObject();

				item.add(new AjaxFallbackLink(WICKETID_BUTTON_DEL) {
					public void onClick(AjaxRequestTarget target) {
							try {
							//delete this entry from the database	
							listViewData.remove(c);
							repaintListViewComponent(listView, listViewData, target,
repaintableContainer);
							} catch (Exception e) {
								onApplicationError(target, e, e.getMessage());
							}
						}
						getTimeLogger().endLoggingPage();
					}
				});
			}
		};
		listView.setReuseItems(true);
		listView.setOutputMarkupId(true);
		repaintableContainer.add(listView);
		add(repaintableContainer);
	}
		
	protected void repaintListViewComponent(ListView repeater, List model,
AjaxRequestTarget target, WebMarkupContainer container) {
		repeater.modelChanging();
		repeater.removeAll();
		repeater.setList(model);
		repeater.modelChanged();		
		target.addComponent(container);
	}
}

-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Consecutive-AJAX-operations-lead-to-Page-Expired-tp2286087p2287076.html
Sent from the Wicket - User 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: Consecutive AJAX operations lead to Page Expired

Posted by Igor Vaynberg <ig...@gmail.com>.
quickstart or it didnt happen

-igor

On Mon, Jul 12, 2010 at 5:57 AM, asarpe <as...@gmail.com> wrote:
>
> Hello all,
>
> I recently encountered a problem where two consecutive AJAX requests from
> inside a panel, lead to a Page Expired exception.
>
> More detailed:
>
> The panel Panel contains a form Form and a ListView LW. Form has an
> AjaxButton who's onSubmit method is implemented to add the content of the
> Form to the DataBase(no errors here) and then update the LW via the button's
> AjaxRequestTarget.
> Everything works just fine the first time. The data ends up in the DataBase,
> the LW is updated via AJAX and gets a new row.
> However if we repeat the operation and try adding a second row to the LW,
> using the same steps, we get the PageExpiredErrorPage.
>
> Any and all ideas are welcomed.
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Consecutive-AJAX-operations-lead-to-Page-Expired-tp2286087p2286087.html
> Sent from the Wicket - User 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
>
>

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