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/05/07 09:57:05 UTC

behavior for onComponentTagBody

Hi all,
I have this in several components:
    @Override
    protected void onComponentTagBody(MarkupStream markupStream,
ComponentTag openTag) {
        String value;
        if (getModel() != null) {
            value = getModelValue();
        } else {
            value = "";
        }
        replaceComponentTagBody(markupStream, openTag,
Consts.getTableBody(getMarkupId(),
                value));
    }

I want to put it in one location such as in an AbstractBehavior.
Unfortunately, this behavior doesn't have this (or something like this)
method.

Is there a way for creating a behavior for the onComponentTagBody or
replaceComponentTagBody?

thanks

-- 
Eyal Golan
egolan74@gmail.com

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

Re: behavior for onComponentTagBody

Posted by Eelco Hillenius <ee...@gmail.com>.
> Johan, Eelco, What do you mean by "Converters"? Is there a special class /
> interface I'm not aware of?

IConverter. See the forminput example of wicket-examples for an idea.

Eelco

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


Re: behavior for onComponentTagBody

Posted by Eyal Golan <eg...@gmail.com>.
Hi all,
Thanks for the replies and sorry for the mess :)
I have MyButton and MyAjaxButton that for now, each overrides the
onComponentTagBody (the one I mentioned above).
I also have a behavior for onComponentTag that works fine.
I thought of putting the onComponentTagBody in the same behavior.

Johan, Eelco, What do you mean by "Converters"? Is there a special class /
interface I'm not aware of?

Thanks


Eyal


On Thu, May 8, 2008 at 10:39 AM, Eelco Hillenius <ee...@gmail.com>
wrote:

> On Wed, May 7, 2008 at 8:42 PM, Igor Vaynberg <ig...@gmail.com>
> wrote:
> > doesnt Label do this already?
>
> Yeah, I think just using getModelValueAsString would give the same results.
>
> Also, Label is the only (or one of the few at most) class(es) where
> overriding onComponentTagBody makes sense. Why not do your thing in a
> base class Eyal?
>
> Or... make model wrappers, where the sole purpose of your wrapping
> models is to format the output of your wrapped models.
>
> Or... do this using converters.
>
> Creating a base class makes sense if you do this with the same kind of
> components all the time (labels I pressume?). If your components are
> very different, any of the other options are fine.
>
> Eelco
>
> ---------------------------------------------------------------------
> 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: behavior for onComponentTagBody

Posted by Martijn Dashorst <ma...@gmail.com>.
I think we miss one call into Eyan's code:

Consts.getTableBody(getMarkupId(), value)

^^^^ seems to be the crux.

Martijn
On 5/8/08, Eelco Hillenius <ee...@gmail.com> wrote:
> On Wed, May 7, 2008 at 8:42 PM, Igor Vaynberg <ig...@gmail.com> wrote:
>  > doesnt Label do this already?
>
>
> Yeah, I think just using getModelValueAsString would give the same results.
>
>  Also, Label is the only (or one of the few at most) class(es) where
>  overriding onComponentTagBody makes sense. Why not do your thing in a
>  base class Eyal?
>
>  Or... make model wrappers, where the sole purpose of your wrapping
>  models is to format the output of your wrapped models.
>
>  Or... do this using converters.
>
>  Creating a base class makes sense if you do this with the same kind of
>  components all the time (labels I pressume?). If your components are
>  very different, any of the other options are fine.
>
>
>  Eelco
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>  For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Buy Wicket in Action: http://manning.com/dashorst
Apache Wicket 1.3.3 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.3

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


Re: behavior for onComponentTagBody

Posted by Eelco Hillenius <ee...@gmail.com>.
On Wed, May 7, 2008 at 8:42 PM, Igor Vaynberg <ig...@gmail.com> wrote:
> doesnt Label do this already?

Yeah, I think just using getModelValueAsString would give the same results.

Also, Label is the only (or one of the few at most) class(es) where
overriding onComponentTagBody makes sense. Why not do your thing in a
base class Eyal?

Or... make model wrappers, where the sole purpose of your wrapping
models is to format the output of your wrapped models.

Or... do this using converters.

Creating a base class makes sense if you do this with the same kind of
components all the time (labels I pressume?). If your components are
very different, any of the other options are fine.

Eelco

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


Re: behavior for onComponentTagBody

Posted by Igor Vaynberg <ig...@gmail.com>.
doesnt Label do this already?

-igor


On Wed, May 7, 2008 at 12:57 AM, Eyal Golan <eg...@gmail.com> wrote:
> Hi all,
>  I have this in several components:
>     @Override
>     protected void onComponentTagBody(MarkupStream markupStream,
>  ComponentTag openTag) {
>         String value;
>         if (getModel() != null) {
>             value = getModelValue();
>         } else {
>             value = "";
>         }
>         replaceComponentTagBody(markupStream, openTag,
>  Consts.getTableBody(getMarkupId(),
>                 value));
>     }
>
>  I want to put it in one location such as in an AbstractBehavior.
>  Unfortunately, this behavior doesn't have this (or something like this)
>  method.
>
>  Is there a way for creating a behavior for the onComponentTagBody or
>  replaceComponentTagBody?
>
>  thanks
>
>  --
>  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: behavior for onComponentTagBody

Posted by Johan Compagner <jc...@gmail.com>.
Or use a converter? Because it seems that is what you are doing?

On 5/7/08, Eyal Golan <eg...@gmail.com> wrote:
> Hi all,
> I have this in several components:
>     @Override
>     protected void onComponentTagBody(MarkupStream markupStream,
> ComponentTag openTag) {
>         String value;
>         if (getModel() != null) {
>             value = getModelValue();
>         } else {
>             value = "";
>         }
>         replaceComponentTagBody(markupStream, openTag,
> Consts.getTableBody(getMarkupId(),
>                 value));
>     }
>
> I want to put it in one location such as in an AbstractBehavior.
> Unfortunately, this behavior doesn't have this (or something like this)
> method.
>
> Is there a way for creating a behavior for the onComponentTagBody or
> replaceComponentTagBody?
>
> thanks
>
> --
> 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