You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by jverstry <jv...@gmail.com> on 2010/07/30 01:07:47 UTC

Question about embedded labels

Hi, 

In the body of an HTML, I have something like this:

<div wicket:id="MyDiv" class="ValueToModify">
    Embedded content to be added
</div>

I have created a label to be able to modify the content of 'class' as
following:

public class MyDivLabel extends Label {
    ...
    @Override
    protected void onComponentTag(ComponentTag tag) {
        super.onComponentTag(tag);
        tag.put("class", "The class value I want to set");
    }
    ...
}

In the web page, I add the labels as following:

...
add(new MyDivLabel("MyDiv","xxx"));
add(new Label("MyEmbedded","My embedded text"));
...

a) Is it ok to embed Labels like I do?
b) How can I make sure the embedded span will not be replaced by "xxx"?

Thanks !!!
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Question-about-embedded-labels-tp2307332p2307332.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: Question about embedded labels

Posted by Jeremy Thomerson <je...@wickettraining.com>.
On Thu, Jul 29, 2010 at 7:13 PM, jverstry <jv...@gmail.com> wrote:

>
> Ok, it compiles. Thanks.
>
> Just one last question about the usage of WebMarkupContainer, because this
> is new to me.
>
> If I create a WebMarkupContainer, will it automatically 'attach' itself to
> the provided html tag using the provided wicket id no matter the type of
> the
> HTML tag? Can I use it to access any wicket-ed HTML tags?
>

Yes.

-- 
Jeremy Thomerson
http://www.wickettraining.com

Re: Question about embedded labels

Posted by jverstry <jv...@gmail.com>.
Ok, it compiles. Thanks.

Just one last question about the usage of WebMarkupContainer, because this
is new to me.

If I create a WebMarkupContainer, will it automatically 'attach' itself to
the provided html tag using the provided wicket id no matter the type of the
HTML tag? Can I use it to access any wicket-ed HTML tags?
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Question-about-embedded-labels-tp2307332p2307399.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: Question about embedded labels

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Why don't they have compilers and code autocompletion in gmail?

On Thu, Jul 29, 2010 at 7:01 PM, Scott Swank <sc...@gmail.com> wrote:

> You can just use:
>
> new AttributeModifier("class", true, Model.of("the-class-name"));
>
> On Thu, Jul 29, 2010 at 4:57 PM, jverstry <jv...@gmail.com> wrote:
> >
> > I just tried to add your code in my code:
> >
> > WebMarkupContainer mydiv = new WebMarkupContainer("MyDiv");
> > mydiv.add(new AttributeModifier("class", true, "the-class-name"));
> > add(mydiv);
> >
> > but it won't compile because the "the-class-name" parameter cannot be a
> > string.
> >
> > I checked the doc and saw that it should be an IModel. This interface is
> > implemented by many classes.
> >
> > Which one should I use?
> > --
> > View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Question-about-embedded-labels-tp2307332p2307380.html
> > Sent from the Wicket - User mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Jeremy Thomerson
http://www.wickettraining.com

Re: Question about embedded labels

Posted by Scott Swank <sc...@gmail.com>.
You can just use:

new AttributeModifier("class", true, Model.of("the-class-name"));

On Thu, Jul 29, 2010 at 4:57 PM, jverstry <jv...@gmail.com> wrote:
>
> I just tried to add your code in my code:
>
> WebMarkupContainer mydiv = new WebMarkupContainer("MyDiv");
> mydiv.add(new AttributeModifier("class", true, "the-class-name"));
> add(mydiv);
>
> but it won't compile because the "the-class-name" parameter cannot be a
> string.
>
> I checked the doc and saw that it should be an IModel. This interface is
> implemented by many classes.
>
> Which one should I use?
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/Question-about-embedded-labels-tp2307332p2307380.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: Question about embedded labels

Posted by Jeremy Thomerson <je...@wickettraining.com>.
new Model<String>("the-class-name")

On Thu, Jul 29, 2010 at 6:57 PM, jverstry <jv...@gmail.com> wrote:

>
> I just tried to add your code in my code:
>
> WebMarkupContainer mydiv = new WebMarkupContainer("MyDiv");
> mydiv.add(new AttributeModifier("class", true, "the-class-name"));
> add(mydiv);
>
> but it won't compile because the "the-class-name" parameter cannot be a
> string.
>
> I checked the doc and saw that it should be an IModel. This interface is
> implemented by many classes.
>
> Which one should I use?
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Question-about-embedded-labels-tp2307332p2307380.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Jeremy Thomerson
http://www.wickettraining.com

Re: Question about embedded labels

Posted by jverstry <jv...@gmail.com>.
I just tried to add your code in my code:

WebMarkupContainer mydiv = new WebMarkupContainer("MyDiv");
mydiv.add(new AttributeModifier("class", true, "the-class-name"));
add(mydiv);

but it won't compile because the "the-class-name" parameter cannot be a
string.

I checked the doc and saw that it should be an IModel. This interface is
implemented by many classes.

Which one should I use?
-- 
View this message in context: http://apache-wicket.1842946.n4.nabble.com/Question-about-embedded-labels-tp2307332p2307380.html
Sent from the Wicket - User mailing list archive at Nabble.com.

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


Re: Question about embedded labels

Posted by Jeremy Thomerson <je...@wickettraining.com>.
You don't need a label for this.  Instead, do this (leave your HTML the
same):

WebMarkupContainer mydiv = new WebMarkupContainer("MyDiv");
mydiv.add(new AttributeModifier("class", true, "the-class-name"));
add(mydiv);

On Thu, Jul 29, 2010 at 6:07 PM, jverstry <jv...@gmail.com> wrote:

>
> Hi,
>
> In the body of an HTML, I have something like this:
>
> <div wicket:id="MyDiv" class="ValueToModify">
>    Embedded content to be added
> </div>
>
> I have created a label to be able to modify the content of 'class' as
> following:
>
> public class MyDivLabel extends Label {
>    ...
>    @Override
>    protected void onComponentTag(ComponentTag tag) {
>        super.onComponentTag(tag);
>        tag.put("class", "The class value I want to set");
>    }
>    ...
> }
>
> In the web page, I add the labels as following:
>
> ...
> add(new MyDivLabel("MyDiv","xxx"));
> add(new Label("MyEmbedded","My embedded text"));
> ...
>
> a) Is it ok to embed Labels like I do?
> b) How can I make sure the embedded span will not be replaced by "xxx"?
>
> Thanks !!!
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Question-about-embedded-labels-tp2307332p2307332.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Jeremy Thomerson
http://www.wickettraining.com