2

I have a question regarding the primefaces component p:selectBooleanCheckbox.

I have following code, which renders a simple boolean checkbox with its label.

<p:selectBooleanCheckbox id="agb" value="#{mobiFormF000001Model.agbChecked}" itemLabel="#{msgs['agb']}">
    <f:ajax render="submit" />
</p:selectBooleanCheckbox>

Now my problem is, that in the label i have an URL, which now is escaped and my label looks like this:

Ich bestätige, dass ich die <a href="http://www.mobi.ch/form-sicherheit-de" target="_blank">Angaben zum Datenschutz</a> gelesen habe und diese akzeptiere.

Is there a way to get that part rendered as link?

2 Answers 2

0

Why don't you simply use <h:outputText> that has the escape property?

<p:selectBooleanCheckbox id="agb" value="#{mobiFormF000001Model.agbChecked}" >
    <f:ajax render="submit" />
</p:selectBooleanCheckbox>
<h:outputText escape="false" value="#{msgs['agb']}" />
3
  • 2
    This would work, but then the text is not a label, which means i can not click it for checking the textbox. And then it is not consistent on my page.
    – Pascal
    Apr 11, 2014 at 8:48
  • For the consistency, it's only a matter of applying the correct style. Concerning the possibility of clicking it, my guess is that the only way is to create a composite component, but that's not an easy task, especially if you want to have the possibility for users to use f:ajax tag.
    – perissf
    Apr 11, 2014 at 8:57
  • Yes, thats right. I would fallback to a basic h:selectBooleanCheckbox but i have the primefaces ajaxLoader on my page, that needs to use p-tags. I'll try to contact the official Forums for primefaces, maybe there is a different approach
    – Pascal
    Apr 11, 2014 at 9:03
0

You can link a p:outputLabel to the checkbox and put any content in its body:

<p:selectBooleanCheckbox value="#{bean.value}"/>
<p:outputLabel for="@previous">
    I agree to the <a href="..." target="_blank">terms and conditions</a>
</p:outputLabel>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.