Ah, I see.

If your popup functionality is pure client-side Javascript, couldn't you
just turn it into a Behavior that you attach to a Label, Image, or
whatever, that sets the "onclick" attribute of whatever you attached it
to?

jk

On Wed, May 30, 2007 at 10:13:40AM -0400, Ravindra Wankar wrote:
>    Thanks John. I was suspecting no one to reply to a long mail.
> 
>    Unfortunately, in my case the getTitle() returns a component not the label
>    text. The component returned by the child can either be a "label" or an
>    "image" component. The derived class gets the label text in its
>    constructor which it uses to construct the label but the parent calls
>    getTitle() too soon.
> 
>    As there are 2 components within the parent (title and contents) that the
>    child needs to fill, I could not use markup inheritance.
> 
>    Thanks,
>    Ravi.
> 
>    John Krasnay wrote:
> 
>  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
>  [email protected]
>  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
>  [email protected]
>  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
> [email protected]
> 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to