You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by datazuul <ra...@pixotec.de> on 2012/04/16 18:18:43 UTC
SimpleFormComponentLabel with page link in label
I am using SimpleFormComponentLabel for getting a clickable "label for=..."
html tag for a input field (checkbox). In the text of the translated
component label I want embed two links. How can this be done?
(wicket:message with embedded components is not the solution as it creates
no "label for..." to the associated text field...)
I need something like this:
<input id="id9" type="checkbox" name="acceptCheckbox">
<label for="id9">I am 18 years old and agree with the ${terms} and
${conditions}.</label>
I tried:
final CheckBox acceptedTerms = new CheckBox("acceptCheckbox",
userModel.bind("userAccount.memberships[0].acceptedTerms"));
form.add(acceptedTerms);
acceptedTerms.setLabel(new ResourceModel("termsAndConditionsCheckLabel"));
acceptedTerms.setRequired(true);
final SimpleFormComponentLabel termsAndConditionsCheckLabel = new
SimpleFormComponentLabel(
"termsAndConditionsCheckLabel", acceptedTerms);
form.add(termsAndConditionsCheckLabel);
final Link terms = new Link("terms", new ResourceModel("terms_of_use")) {
private static final long serialVersionUID = 1L;
@Override
public void onClick() {
setResponsePage(TermsOfUsePage.class);
}
};
termsAndConditionsCheckLabel.add(terms);
but did not work (result: I am 18 years old and agree with the ${terms} and
conditions.)
Messages:
<entry key="termsAndConditionsCheckLabel">I am 18 years old and agree with
the ${terms} and conditions.</entry>
<entry key="terms_of_use">Terms of Use</entry>
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/SimpleFormComponentLabel-with-page-link-in-label-tp4562036p4562036.html
Sent from the Users forum 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: SimpleFormComponentLabel with page link in label
Posted by datazuul <ra...@pixotec.de>.
Found the solution!
Not using SimpleFormComponentLabel as it is replacing it's content, but
using FormComponentLabel (to get for=... attribute) in combination with the
wicket:message solution:
final FormComponentLabel termsAndConditionsCheckLabel = new
FormComponentLabel("termsAndConditionsCheckLabel", acceptedTerms);
form.add(termsAndConditionsCheckLabel);
final Link terms = new Link("terms") {
private static final long serialVersionUID = 1L;
@Override
public void onClick() {
setResponsePage(TermsOfUsePage.class);
}
};
termsAndConditionsCheckLabel.add(terms);
final Label termsOfUse = new Label("terms_of_use", new
ResourceModel("terms_of_use"));
termsOfUse.setRenderBodyOnly(true);
terms.add(termsOfUse);
Markup:
<label wicket:id="termsAndConditionsCheckLabel">
<wicket:message key="termsAndConditionsCheckLabel">Ich bin mindestens 18
Jahre alt und mit den <a href="#" wicket:id="terms"><span
wicket:id="terms_of_use">AGB's</span></a> und den
Datenschutzbestimmungen einverstanden.</wicket:message></label>
Messages:
<entry key="termsAndConditionsCheckLabel">I am 18 years old and agree with
the ${terms} and conditions.</entry>
<entry key="terms_of_use">Terms of Use</entry>
I will add this solution to the Wiki! ;-)
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/SimpleFormComponentLabel-with-page-link-in-label-tp4562036p4562365.html
Sent from the Users forum 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