You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Eyal Golan <eg...@gmail.com> on 2008/03/26 17:43:52 UTC

Extending Button

Hello all,
we want to create a styled button for our application.
Each button can be of different size and we want to use localization for the
text so we thought about creating 3 images for our buttons.
left gif, middle gif and right gif.

I want to create a new component that rendered itself to something like:
<img .....> <input type="submit" ...> <img....>

If there is already something like that, I would love using it.
If not, I would be even more glad creating it.

Here's something I started:

package com.....components;

import org.apache.wicket.markup.ComponentTag;
import org.apache.wicket.markup.MarkupStream;
import org.apache.wicket.markup.html.WebMarkupContainerWithAssociatedMarkup;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.model.IModel;

public abstract class MyButton extends
WebMarkupContainerWithAssociatedMarkup {
    private static final long serialVersionUID = -5168724130685807087L;
    private final Button button;

    public MyButton(String id) {
        super(id);
        button = new Button("eurekifyButton");
    }

    public MyButton(String id, IModel model) {
        super(id, model);
        button = new Button("eurekifyButton", model);
    }

    @Override
    protected void onComponentTag(ComponentTag tag) {
        // TODO Auto-generated method stub
        super.onComponentTag(tag);
    }

    @Override
    protected void onComponentTagBody(MarkupStream markupStream,
ComponentTag openTag) {
        // TODO Auto-generated method stub
        super.onComponentTagBody(markupStream, openTag);
    }

    public abstract void onSubmit();
}

The onSubmit is to imitate the onSubmit of a button.

Is the component should be WebMarkupContainerWithAssociatedMarkup or just
WebMarkupContainer?
Is a Panel good candidate? (I believe not).

Any help would be appreciated.
It seems that this is my first "more that a trivial" reusable component.

Thanks guys,
This users list is most helpful.


-- 
Eyal Golan
egolan74@gmail.com

Visit: http://jvdrums.sourceforge.net/

Re: Extending Button

Posted by Eyal Golan <eg...@gmail.com>.
many thanks



On Wed, Mar 26, 2008 at 7:44 PM, Igor Vaynberg <ig...@gmail.com>
wrote:

> class mybutton extends button {
>
>   public mybutton(...) {
>      add(new abstractbehavior() {
>         beforerender(component c) {
>            c.getresponse().write("<img src=\""+url+"\"/>");
>         }
>         afterrender(component c) { // ditto }
>      }
>   }
> }
>
> -igor
>
>
> On Wed, Mar 26, 2008 at 10:40 AM, Eyal Golan <eg...@gmail.com> wrote:
> > thanks,
> >  can you please explain it more detailed ?
> >
> >  On Wed, Mar 26, 2008 at 7:25 PM, Igor Vaynberg <igor.vaynberg@gmail.com
> >
> >  wrote:
> >
> >
> >
> >  > personally, if all you really need are the img tags i would use a
> >  > behavior and spit out the img tags in before/after render
> >  >
> >  > -igor
> >  >
> >  >
> >  > On Wed, Mar 26, 2008 at 9:43 AM, Eyal Golan <eg...@gmail.com>
> wrote:
> >  > > Hello all,
> >  > >  we want to create a styled button for our application.
> >  > >  Each button can be of different size and we want to use
> localization
> >  > for the
> >  > >  text so we thought about creating 3 images for our buttons.
> >  > >  left gif, middle gif and right gif.
> >  > >
> >  > >  I want to create a new component that rendered itself to something
> >  > like:
> >  > >  <img .....> <input type="submit" ...> <img....>
> >  > >
> >  > >  If there is already something like that, I would love using it.
> >  > >  If not, I would be even more glad creating it.
> >  > >
> >  > >  Here's something I started:
> >  > >
> >  > >  package com.....components;
> >  > >
> >  > >  import org.apache.wicket.markup.ComponentTag;
> >  > >  import org.apache.wicket.markup.MarkupStream;
> >  > >  import
> >  > org.apache.wicket.markup.html.WebMarkupContainerWithAssociatedMarkup;
> >  > >  import org.apache.wicket.markup.html.form.Button;
> >  > >  import org.apache.wicket.model.IModel;
> >  > >
> >  > >  public abstract class MyButton extends
> >  > >  WebMarkupContainerWithAssociatedMarkup {
> >  > >     private static final long serialVersionUID =
> -5168724130685807087L;
> >  > >     private final Button button;
> >  > >
> >  > >     public MyButton(String id) {
> >  > >         super(id);
> >  > >         button = new Button("eurekifyButton");
> >  > >     }
> >  > >
> >  > >     public MyButton(String id, IModel model) {
> >  > >         super(id, model);
> >  > >         button = new Button("eurekifyButton", model);
> >  > >     }
> >  > >
> >  > >     @Override
> >  > >     protected void onComponentTag(ComponentTag tag) {
> >  > >         // TODO Auto-generated method stub
> >  > >         super.onComponentTag(tag);
> >  > >     }
> >  > >
> >  > >     @Override
> >  > >     protected void onComponentTagBody(MarkupStream markupStream,
> >  > >  ComponentTag openTag) {
> >  > >         // TODO Auto-generated method stub
> >  > >         super.onComponentTagBody(markupStream, openTag);
> >  > >     }
> >  > >
> >  > >     public abstract void onSubmit();
> >  > >  }
> >  > >
> >  > >  The onSubmit is to imitate the onSubmit of a button.
> >  > >
> >  > >  Is the component should be WebMarkupContainerWithAssociatedMarkup
> or
> >  > just
> >  > >  WebMarkupContainer?
> >  > >  Is a Panel good candidate? (I believe not).
> >  > >
> >  > >  Any help would be appreciated.
> >  > >  It seems that this is my first "more that a trivial" reusable
> >  > component.
> >  > >
> >  > >  Thanks guys,
> >  > >  This users list is most helpful.
> >  > >
> >  > >
> >  > >  --
> >  > >  Eyal Golan
> >  > >  egolan74@gmail.com
> >  > >
> >  > >  Visit: http://jvdrums.sourceforge.net/
> >  > >
> >  >
> >  > ---------------------------------------------------------------------
> >  > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >  > For additional commands, e-mail: users-help@wicket.apache.org
> >  >
> >  >
> >
> >
> >  --
> >
> >
> > Eyal Golan
> >  egolan74@gmail.com
> >
> >  Visit: http://jvdrums.sourceforge.net/
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Eyal Golan
egolan74@gmail.com

Visit: http://jvdrums.sourceforge.net/

Re: Extending Button

Posted by Igor Vaynberg <ig...@gmail.com>.
class mybutton extends button {

   public mybutton(...) {
      add(new abstractbehavior() {
         beforerender(component c) {
            c.getresponse().write("<img src=\""+url+"\"/>");
         }
         afterrender(component c) { // ditto }
      }
   }
}

-igor


On Wed, Mar 26, 2008 at 10:40 AM, Eyal Golan <eg...@gmail.com> wrote:
> thanks,
>  can you please explain it more detailed ?
>
>  On Wed, Mar 26, 2008 at 7:25 PM, Igor Vaynberg <ig...@gmail.com>
>  wrote:
>
>
>
>  > personally, if all you really need are the img tags i would use a
>  > behavior and spit out the img tags in before/after render
>  >
>  > -igor
>  >
>  >
>  > On Wed, Mar 26, 2008 at 9:43 AM, Eyal Golan <eg...@gmail.com> wrote:
>  > > Hello all,
>  > >  we want to create a styled button for our application.
>  > >  Each button can be of different size and we want to use localization
>  > for the
>  > >  text so we thought about creating 3 images for our buttons.
>  > >  left gif, middle gif and right gif.
>  > >
>  > >  I want to create a new component that rendered itself to something
>  > like:
>  > >  <img .....> <input type="submit" ...> <img....>
>  > >
>  > >  If there is already something like that, I would love using it.
>  > >  If not, I would be even more glad creating it.
>  > >
>  > >  Here's something I started:
>  > >
>  > >  package com.....components;
>  > >
>  > >  import org.apache.wicket.markup.ComponentTag;
>  > >  import org.apache.wicket.markup.MarkupStream;
>  > >  import
>  > org.apache.wicket.markup.html.WebMarkupContainerWithAssociatedMarkup;
>  > >  import org.apache.wicket.markup.html.form.Button;
>  > >  import org.apache.wicket.model.IModel;
>  > >
>  > >  public abstract class MyButton extends
>  > >  WebMarkupContainerWithAssociatedMarkup {
>  > >     private static final long serialVersionUID = -5168724130685807087L;
>  > >     private final Button button;
>  > >
>  > >     public MyButton(String id) {
>  > >         super(id);
>  > >         button = new Button("eurekifyButton");
>  > >     }
>  > >
>  > >     public MyButton(String id, IModel model) {
>  > >         super(id, model);
>  > >         button = new Button("eurekifyButton", model);
>  > >     }
>  > >
>  > >     @Override
>  > >     protected void onComponentTag(ComponentTag tag) {
>  > >         // TODO Auto-generated method stub
>  > >         super.onComponentTag(tag);
>  > >     }
>  > >
>  > >     @Override
>  > >     protected void onComponentTagBody(MarkupStream markupStream,
>  > >  ComponentTag openTag) {
>  > >         // TODO Auto-generated method stub
>  > >         super.onComponentTagBody(markupStream, openTag);
>  > >     }
>  > >
>  > >     public abstract void onSubmit();
>  > >  }
>  > >
>  > >  The onSubmit is to imitate the onSubmit of a button.
>  > >
>  > >  Is the component should be WebMarkupContainerWithAssociatedMarkup or
>  > just
>  > >  WebMarkupContainer?
>  > >  Is a Panel good candidate? (I believe not).
>  > >
>  > >  Any help would be appreciated.
>  > >  It seems that this is my first "more that a trivial" reusable
>  > component.
>  > >
>  > >  Thanks guys,
>  > >  This users list is most helpful.
>  > >
>  > >
>  > >  --
>  > >  Eyal Golan
>  > >  egolan74@gmail.com
>  > >
>  > >  Visit: http://jvdrums.sourceforge.net/
>  > >
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  > For additional commands, e-mail: users-help@wicket.apache.org
>  >
>  >
>
>
>  --
>
>
> Eyal Golan
>  egolan74@gmail.com
>
>  Visit: http://jvdrums.sourceforge.net/
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Extending Button

Posted by Eyal Golan <eg...@gmail.com>.
thanks,
can you please explain it more detailed ?

On Wed, Mar 26, 2008 at 7:25 PM, Igor Vaynberg <ig...@gmail.com>
wrote:

> personally, if all you really need are the img tags i would use a
> behavior and spit out the img tags in before/after render
>
> -igor
>
>
> On Wed, Mar 26, 2008 at 9:43 AM, Eyal Golan <eg...@gmail.com> wrote:
> > Hello all,
> >  we want to create a styled button for our application.
> >  Each button can be of different size and we want to use localization
> for the
> >  text so we thought about creating 3 images for our buttons.
> >  left gif, middle gif and right gif.
> >
> >  I want to create a new component that rendered itself to something
> like:
> >  <img .....> <input type="submit" ...> <img....>
> >
> >  If there is already something like that, I would love using it.
> >  If not, I would be even more glad creating it.
> >
> >  Here's something I started:
> >
> >  package com.....components;
> >
> >  import org.apache.wicket.markup.ComponentTag;
> >  import org.apache.wicket.markup.MarkupStream;
> >  import
> org.apache.wicket.markup.html.WebMarkupContainerWithAssociatedMarkup;
> >  import org.apache.wicket.markup.html.form.Button;
> >  import org.apache.wicket.model.IModel;
> >
> >  public abstract class MyButton extends
> >  WebMarkupContainerWithAssociatedMarkup {
> >     private static final long serialVersionUID = -5168724130685807087L;
> >     private final Button button;
> >
> >     public MyButton(String id) {
> >         super(id);
> >         button = new Button("eurekifyButton");
> >     }
> >
> >     public MyButton(String id, IModel model) {
> >         super(id, model);
> >         button = new Button("eurekifyButton", model);
> >     }
> >
> >     @Override
> >     protected void onComponentTag(ComponentTag tag) {
> >         // TODO Auto-generated method stub
> >         super.onComponentTag(tag);
> >     }
> >
> >     @Override
> >     protected void onComponentTagBody(MarkupStream markupStream,
> >  ComponentTag openTag) {
> >         // TODO Auto-generated method stub
> >         super.onComponentTagBody(markupStream, openTag);
> >     }
> >
> >     public abstract void onSubmit();
> >  }
> >
> >  The onSubmit is to imitate the onSubmit of a button.
> >
> >  Is the component should be WebMarkupContainerWithAssociatedMarkup or
> just
> >  WebMarkupContainer?
> >  Is a Panel good candidate? (I believe not).
> >
> >  Any help would be appreciated.
> >  It seems that this is my first "more that a trivial" reusable
> component.
> >
> >  Thanks guys,
> >  This users list is most helpful.
> >
> >
> >  --
> >  Eyal Golan
> >  egolan74@gmail.com
> >
> >  Visit: http://jvdrums.sourceforge.net/
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Eyal Golan
egolan74@gmail.com

Visit: http://jvdrums.sourceforge.net/

Re: Extending Button

Posted by Igor Vaynberg <ig...@gmail.com>.
personally, if all you really need are the img tags i would use a
behavior and spit out the img tags in before/after render

-igor


On Wed, Mar 26, 2008 at 9:43 AM, Eyal Golan <eg...@gmail.com> wrote:
> Hello all,
>  we want to create a styled button for our application.
>  Each button can be of different size and we want to use localization for the
>  text so we thought about creating 3 images for our buttons.
>  left gif, middle gif and right gif.
>
>  I want to create a new component that rendered itself to something like:
>  <img .....> <input type="submit" ...> <img....>
>
>  If there is already something like that, I would love using it.
>  If not, I would be even more glad creating it.
>
>  Here's something I started:
>
>  package com.....components;
>
>  import org.apache.wicket.markup.ComponentTag;
>  import org.apache.wicket.markup.MarkupStream;
>  import org.apache.wicket.markup.html.WebMarkupContainerWithAssociatedMarkup;
>  import org.apache.wicket.markup.html.form.Button;
>  import org.apache.wicket.model.IModel;
>
>  public abstract class MyButton extends
>  WebMarkupContainerWithAssociatedMarkup {
>     private static final long serialVersionUID = -5168724130685807087L;
>     private final Button button;
>
>     public MyButton(String id) {
>         super(id);
>         button = new Button("eurekifyButton");
>     }
>
>     public MyButton(String id, IModel model) {
>         super(id, model);
>         button = new Button("eurekifyButton", model);
>     }
>
>     @Override
>     protected void onComponentTag(ComponentTag tag) {
>         // TODO Auto-generated method stub
>         super.onComponentTag(tag);
>     }
>
>     @Override
>     protected void onComponentTagBody(MarkupStream markupStream,
>  ComponentTag openTag) {
>         // TODO Auto-generated method stub
>         super.onComponentTagBody(markupStream, openTag);
>     }
>
>     public abstract void onSubmit();
>  }
>
>  The onSubmit is to imitate the onSubmit of a button.
>
>  Is the component should be WebMarkupContainerWithAssociatedMarkup or just
>  WebMarkupContainer?
>  Is a Panel good candidate? (I believe not).
>
>  Any help would be appreciated.
>  It seems that this is my first "more that a trivial" reusable component.
>
>  Thanks guys,
>  This users list is most helpful.
>
>
>  --
>  Eyal Golan
>  egolan74@gmail.com
>
>  Visit: http://jvdrums.sourceforge.net/
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org