I forgot,

A possible solution would be using a shared StringResourceModel for both the
setLabel() method and providing the <label> tag like this:

<label wicket:id="labelX"><span wicket:id="labelXText"></span></label>

StringResourceModel m = new StringResourceModel("form.x.label", this, null);
x.setLabel(m);
FormComponentLabel labelX = new FormComponentLabel("labelX", x);
form.add(labelX);
Label labelXText = new Label("labelXText", m);

But I'm looking for a less intrusive solution on pages already developed...

Thanks,
Xavier

---------- Forwarded message ----------
From: Xavier López <xavil...@gmail.com>
Date: 2009/11/25
Subject: Component.setLabel and <label> tags
To: users@wicket.apache.org


Hi,

In a form, I have multiple fields each one with its corresponding
FormComponentLabel, with proper <wicket:message> content in the markup file.
Now, I'm facing the fact that I need to provide the same keys I provided in
<wicket:message> in a StringResourceModel in component's setLabel() method.

Although I'm aware it's not straightforward (setLabel requires a Model, and
<label>'s body is just body markup), it would be great if there was some way
to avoid this duplication telling Wicket to use the same key provided in the
FormComponentLabel's body...

Does anyone have a hint ?

Thanks,
Xavier




-- 
"Klein bottle for rent--inquire within."

Reply via email to