One way to solve the "abstract method from the constructor" problem (or
more precisely, the "non-final method from the constructor" problem) is
to use a Model, e.g...

public class PopupPanel extends Panel {
    public abstract String getTitle();
    public PopupPanel(String id) {
        add(new Label("foo", new AbstractReadOnlyModel() {
            public Object getObject(Component component) {
                return getTitle();
            }
        }
    }
}

The model's getObject is only called some time after the object has
been constructed.

jk

    
On Tue, May 29, 2007 at 07:36:59AM -0400, Ravindra Wankar wrote:
> 
> This looks more like a design question but I think there must be a 
> better, Wicket way.
> 
> I wrote a PopupPanel that allows you to have a "div" popup in a page by 
> clicking a link. The contents of the div can be static/loaded via Ajax. 
> The popup part with Ajax is working. The link that activates the popup 
> can either have an image or text label. So I have...
> 
>                               PopupPanel
>                                   | abstract getTitle() and getContent()
>                                   | constructor calls getTitle() and 
> getContents()
>                                   | 
>             --------------------------------------
>             |                                    |
>    LabelLinkedPopupPanel                ImageLinkedPopupPanel
>        implements getTitle()              implements getTitle()
> 
> 
> To use it, new LabelLinkedPopupPanel(...) and override the getContent() 
> method. I can't get the title to work because of "abstract method from 
> the constructor" problem. My options then are
> 
> 1. Have a setTitle() and setContent() method that is called by the 
> subclasses but failing to call them won't be caught till runtime.
> 2. Have PopupPanel constructor take in components for title and content. 
> The sub classes then just act as wrappers.
> 3. Replace the subclasses with PopupPanelFactory with 2 methods 
> newLabelLinkedPopup() and newImageLinkedPopup.
> 
> I don't think a border suits this requirement but I'm not sure. Is there 
> a better way?
> 
> Thanks
> Ravi
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to