package com.worldturner.commons.wicket.panel; import org.apache.wicket.markup.html.panel.Panel; import org.apache.wicket.model.IModel; /** * * @author Erwin Bolwidt (ebolwidt@worldturner.com) * * @param * The model object type. */ public class GenericPanel extends Panel { private static final long serialVersionUID = 1L; public GenericPanel(String id, IModel model) { super(id, model); } public GenericPanel(String id) { super(id); } /** * Initialization method which will be invoked once, right before the first time the component is rendered. At this * point, this Panel has been added to its parent container, and any model that should have been set, has been set. *

* This implementation does nothing. Override this method in your subclass. */ protected void initializeGui() { } /** * Takes care of initialization at the first time that the component is rendered. If this method is overridden in a * subclass, take care to invoke this method in your superclass. */ @Override protected void onBeforeRender() { if (!hasBeenRendered()) { initializeGui(); } super.onBeforeRender(); } /** * Returns the default model object of this Panel, typed correctly according to the type parametrization. * * @return */ public T getModelObject() { return getModel().getObject(); } /** * Returns the default model of this Panel, typed correctly according to the type parametrization. * * @return */ @SuppressWarnings("unchecked") public IModel getModel() { return (IModel) getDefaultModel(); } /** * Installs the default model of this Panel. * * @param model * the model to install. */ public final void setModel(IModel model) { setDefaultModel(model); } /** * Sets model object in the default model of this Panel. * * @param object * the model object to set. */ public final void setModelObject(T object) { setDefaultModelObject(object); } }