Hello, I am working on a library based on wicket framework and I couldnt find some suitable solution when creating component hierarchies. For example I have a base class AbstractLink for links (DownloadLink, LabelLink, IconLink, SubmitLink, ...):
public abstract class AbstractLink extends Panel { private ILinkComponent linkComponent; private boolean attached= false; protected void onBeforeRender() { if(!attached) { removeAll(); linkComponent = createLinkComponent(); linkComponent.setWidht(150, Unit.PX); add(linkComponent); attached = true; } } protected abstract ILinkComponent createLinkComponent(String id); // PROBLEM METHOD - NOT SURE that linkComponent exists public void setTooltip(IModel tooltip) { linkComponent.setTooltip(tootlip); } } public abstract class LabelLink extends AbstractLink { private IModel labelModel; public LabelLink(IModel labelModel) { this.labelModel= labelModel; } protected ILinkComponent createLinkComponent(String id) { Link linkComponent = new Link(id); linkComponent.add(new Label(labelModel)); return linkComponent; } } Subclassing panels are responsible for creating linkComponent. Overriden method createLinkComponent() usually uses attribute from subclass (labelModel in LabelLink). For this reason I couldnt call createLinkComponent in AbstractLink's constructor (LabelLink attribute labelModel is null). So I use the trick with onBeforeRender method. The problem is that I couldnt write methods (setTooltip) delegating to linkComponent in AbstractLink, because i cannot be sure that linkComponent exists. Is there someone who solved this sort of problem? Or how do you handle similar situations? Thanks, michal --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org