Hello everybody,
I just wanted to dive a little into wicket i18n, and stumbled upon this:
Say I have page with this simple form:
Form form = new Form("form");
add(form);
FeedbackPanel feedback = new FeedbackPanel("feedback");
form.add(feedback);
TextField tx = new TextField("text");
tx.setRequired(true);
form.add(tx);
and corresponding properties file for the page:
form.text=FormTexti18n
When I submit the empty form, I get the message:
field 'FormTexti18n' is required.
So, my label from the properties is used for the validation message. So
far, so good.
Now I'd like to have a label for the TextField, displaying the same
string from the properties. Also, a normal Label is not enough for me,
I'd like to change its CSS style depending on having an error.
So I start with this:
SimpleFormComponentLabel label =
new SimpleFormComponentLabel("textLabel", tx);
form.add(label);
Now I get an error:
java.lang.IllegalStateException: Provided form component does not have a
label set. Use FormComponent.setLabel(IModel) to set the model that will
feed this label
at
wicket.markup.html.form.SimpleFormComponentLabel.<init>(SimpleFormComponentLabel.java:46)
Okay, this error tells me what to do, and I could do a
tx.setLabel(new ResourceModel("form.textLabel"));
And everything works fine. But ... :-)
Is this really necessary? This ResourceModel is only required for the
SimpleFormComponentLabel, I already have label through the properties!
The JavaDoc FormComponent#getModel() says
"The value will be made available to the validator property by means of
${label}."
Which it does, but I'm wondering why SimpleFormComponentLabel can't do
this the same way as the validator? Or is this one of those issues which
will be gone with the changes in 2.0?
greetings,
Rüdiger
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user