wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jensiator <jens.alen...@gmail.com>
Subject Re: Wizard clear all formfields
Date Wed, 16 May 2012 09:49:00 GMT
Ended up with this:
public class ClearFormComponentWizardStep extends WizardStep {

	public ClearFormComponentWizardStep(String pTitleMessageKey) {
		this(pTitleMessageKey, new Model<String>(""));
	}

	public ClearFormComponentWizardStep(String pTitleMessageKey, IModel<?
extends Serializable> pModel) {
		super(pTitleMessageKey, pModel);
	}

	@Override
	public Component getView(String pId, Component pParent, IWizard pWizard) {
		WebMarkupContainer view = (WebMarkupContainer) super.getView(pId, pParent,
pWizard);
		if(isTimeToClear()) {
			clearAllFormComponent(view);
		}
		return view;
	}

	/**
	 * Can be overriden for changing the clearAllForm behavior
	 * 
	 * @param pView
	 */
	protected void clearAllFormComponent(WebMarkupContainer pView) {
		pView.visitChildren(FormComponent.class, new
Component.IVisitor<FormComponent&lt;?>>() {
			@Override
			public Object component(FormComponent<?> pFormComponent) {
				pFormComponent.clearInput();
				return Component.IVisitor.CONTINUE_TRAVERSAL;
			}
		});
	}

	/**
	 * Override this if any other parameter would affect
clearAllFormComponentCode
	 * 
	 * @return
	 */
	protected boolean isTimeToClear() {
		return true;
	}

}

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Wizard-clear-all-formfields-tp4634057p4641106.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


Mime
View raw message