I would go a completely different route: add an AttributeModifier [1]. It 
should look something like this:

Label  label = new Label("label", Model.of("Text"));
label.add(new AttributeModifier("class", Model.of("cssClassName")));

This is explained in more detail in the wicket-guide [2], Chapter 4.2.

Alasdair

[1] 
http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/AttributeModifier.html
[2] http://code.google.com/p/wicket-guide/ 

-----Ursprüngliche Nachricht-----
Von: Lucio Crusca [mailto:lu...@sulweb.org] 
Gesendet: Dienstag, 27. August 2013 13:16
An: users@wicket.apache.org
Betreff: Re: Styling <label> tags

In data lunedì 26 agosto 2013 11:28:27, francois meillet ha scritto:
> have a look to
> 
> http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/m
> arkup /html/form/FormComponentLabel.html and 
> http://ci.apache.org/projects/wicket/apidocs/6.0.x/org/apache/wicket/m
> arkup /html/form/SimpleFormComponentLabel.html
> 
> François

I've had a look, but I'm afraid I need a little example. I have the following
markup:

<wicket:panel>
  <label wicket:for="input">
    <span wicket:id="inputSpan">[label text]</span>
    <input wicket:id="input" type="checkbox" />
  </label>
</wicket:panel>

and the following (simplified) java code:

public class LabeledCheckbox extends Panel {
  public LabeledCheckbox(String id, String uiText, IModel<Boolean> model)
  {
    super(id);
    Label spanLabel = new Label("inputSpan", uiText);
    add(spanLabel.setRenderBodyOnly(false));
    CheckBox cb = new checkBox("input", model);
    cb.setLabel(Model.of(uiText));
    add(cb);
    setRenderBodyOnly(true);
  }
}

If I add a FormComponentLabel then I need to specify its wicket:id attribute, 
but I can't use both wicket:id and wicket:for attributes together.

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


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

Reply via email to