You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

Passing HTTP Parameters To Ajax Callback Methods

The following example demonstrates capturing the window position and adding a URL parameter to the Ajax request (assumes "window.pos" exists):

	webPage.add(new AbstractAjaxTimerBehavior(duration) {
		private static final long serialVersionUID = 1L;

		/**
		 * {@inheritDoc}
		 */
		@Override
		public final CharSequence getCallbackUrl(final boolean onlyTargetActivePage) {
			return super.getCallbackUrl(onlyTargetActivePage)) + "&pos=window.pos";
		}

		/**
		 * {@inheritDoc}
		 */
		@Override
		protected final void onTimer(final AjaxRequestTarget target) {
			final String pos = getRequest().getParameter("pos");
			// process pos ...
		}
	});
  • No labels