Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

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):

Code Block
	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 ...
		}
	});