Wicket 1.4.10 released

This is the tenth maintenance release of the 1.4.x series and brings over thirty bug fixes and improvements.

As well as bringing bug fixes and small improvements, 1.4.10 brings two major new features:

  • Delayed component initialization
  • Component configuration

Delayed component initialization allows developers to initialize their components outside of a constructor, when more environment is available to the component instance. From the javadoc:

public class Component {
	/**
	 * This method is meant to be used as an alternative to initialize components. Usually the
	 * component's constructor is used for this task, but sometimes a component cannot be
	 * initialized in isolation, it may need to access its parent component or its markup in order
	 * to fully initialize. This method is invoked once per component's lifecycle when a path exists
	 * from this component to the {@link Page} thus providing the component with an atomic callback
	 * when the component's environment is built out.
	 * <p>
	 * Overrides must call super#{@link #onInitialize()}. Usually this should be the first thing an
	 * override does, much like a constructor.
	 * </p>
	 * <p>
	 * Parent containers are guaranteed to be initialized before their children
	 * </p>
	 * <p>
	 * It is safe to use {@link #getPage()} in this method
	 * </p>
	 * 
	 * <p>
	 * NOTE:The timing of this call is not precise, the contract is that it is called sometime
	 * before {@link Component#onBeforeRender()}.
	 * </p>
	 * 
	 */
	protected void onInitialize() {}
}

Component configuration allows developers to easier configure component states such as visibility, enabled, etc. From the javadoc:

public class Component {
	/**
	 * Called once per request on components before they are about to be rendered. This method
	 * should be used to configure such things as visibility and enabled flags.
	 * <p>
	 * Overrides must call {@code super.onConfigure()}, usually before any other code
	 * </p>
	 * <p>
	 * NOTE: Component hierarchy should not be modified inside this method, instead it should be
	 * done in {@link #onBeforeRender()}
	 * </p>
	 * <p>
	 * NOTE: Why this method is preferrable to directly overriding {@link #isVisible()} and
	 * {@link #isEnabled()}? Because those methods are called multiple times even for processing of
	 * a single request. If they contain expensive logic they can slow down the response time of the
	 * entire page. Further, overriding those methods directly on form components may lead to
	 * inconsistent or unexpected state depending on when those methods are called in the form
	 * processing workflow. It is a better practice to push changes to state rather than pull.
	 * </p>
	 * <p>
	 * NOTE: If component's visibility or another property depends on another component you may call
	 * {@code other.configure()} followed by {@code other.isVisible()} as mentioned in
	 * {@link #configure()} javadoc.
	 * </p>
	 * <p>
	 * NOTE: Why should {@link #onBeforeRender()} not be used for this? Because if visibility of a
	 * component is toggled inside {@link #onBeforeRender()} another method needs to be overridden
	 * to make sure {@link #onBeforeRender()} will be invoked on ivisible components:
	 * 
	 * <pre>
	 * class MyComponent extends WebComponent
	 * {
	 * 	protected void onBeforeRender()
	 * 	{
	 * 		setVisible(Math.rand() &gt; 0.5f);
	 * 		super.onBeforeRender();
	 * 	}
	 * 
	 * 	// if this override is forgotten, once invisible component will never become visible
	 * 	protected boolean callOnBeforeRenderIfNotVisible()
	 * 	{
	 * 		return true;
	 * 	}
	 * }
	 * </pre>
	 * 
	 * VS
	 * 
	 * <pre>
	 * class MyComponent extends WebComponent
	 * {
	 * 	protected void onConfigure()
	 * 	{
	 * 		setVisible(Math.rand() &gt; 0.5f);
	 * 		super.onConfigure();
	 * 	}
	 * }
	 * </pre>
	 */
	protected void onConfigure() {}
}
<dependency>
    <groupId>org.apache.wicket</groupId>
    <artifactId>wicket</artifactId>
    <version>1.4.10</version>
</dependency>