
import org.apache.wicket.PageParameters;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.ajax.markup.html.form.AjaxButton;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.form.*;

/**
 * Homepage
 */
public class Dummy extends WebPage
{
	private static final long serialVersionUID = 1L;
	boolean doingStuffWithAjax;

	/**
	 * Constructor that is invoked when page is invoked without a session.
	 * @param parameters	Page parameters
	 */
	public Dummy(final PageParameters parameters)
	{
		// AJAX
		
		final WebMarkupContainer wmc2 = new WebMarkupContainer("wmc2");
		// wmc2.setOutputMarkupId(true);
		wmc2.setOutputMarkupPlaceholderTag(true);
		add(wmc2);

		final AjaxLink links[] = new AjaxLink[2];

		wmc2.add(links[0] = new AjaxLink("doStuff") {
			private static final long serialVersionUID = 1L;
			@Override
			public void onClick(AjaxRequestTarget target)
			{
				doingStuffWithAjax = true;
				System.err.println("true");
				target.addComponent(wmc2);
				// target.addComponent(links[0]);
				// target.addComponent(links[1]);
			}
			@Override
			public boolean isVisible()
			{
				return !doingStuffWithAjax;
			}
		});

		wmc2.add(links[1] = new AjaxLink("cancel") {
			private static final long serialVersionUID = 1L;
			@Override
			public void onClick(AjaxRequestTarget target)
			{
				doingStuffWithAjax = false;
				System.err.println("false");
				target.addComponent(wmc2);
				// target.addComponent(links[0]);
				// target.addComponent(links[1]);
			}
			@Override
			public boolean isVisible()
			{
				return doingStuffWithAjax;
			}
		});

		// links[0].setOutputMarkupPlaceholderTag(true);
		// links[1].setOutputMarkupPlaceholderTag(true);
	}
}
		
