Tobago Demo

Menu

Out

The <tc:out/> display an outputtext combined with a label.

Tag Library Documentation

Basics

To put a label in front of a outputtext, use the label attribute.

<tc:out label="Output" value="Some Text"/> Some Text Output without a label

Skip with compact

If using labelLayout="skip" there is still a tag surrounding the output text.

This text is rendered by tc:out with labelLayout=skip.

Set compact="true" to remove the surrounding tag as well.

This text is rendered by tc:out with labelLayout=skip and compact=true.

Markups

thin
normal
bold
italic
primary
secondary
success
danger
warning
info
light
dark
muted
deleted
number
large
small
combination: deleted danger italic

Message Format

Using message formatting for i18n strings. <tc:out value="#{demoBundle.message_format_example}" messageFormat="true"> <f:param value="Mrs"/> <f:param value="Smith"/> </tc:out> Welcome Mrs Smith!

Escape

If the given string to the output field is HTML/XML code, it will be escaped by default. But you can turn it off with the escape attribute.

Escape on (default)

<tc:out label="Escape on (default)" escape="true" value="#{outController.html}"/> Text in <span style='color:#FF0000'>red</span>, <span style='color:#00FF00'>green</span> and <span style='color:#0000FF'>blue</span>.

Escape off

Although the HTML code is not escaped, you can see, that the text is not colored. This is, because the code is sanitzed (see next section).

<tc:out label="Escape off" escape="false" value="#{outController.html}"/> Text in red, green and blue.

Sanitize

Sanitize remove HTML/XML-Tags from a given string if not escaped. It can be configured in the tobago-config.xml. If you want to write your own sanitizer, you have to implement org.apache.myfaces.tobago.sanitizer.Sanitizer.

Sanitzing can be deactivated for a component using the sanitize attribute. But be careful, because of XSS vulnerability.

<tc:out label="Sanitize off" escape="false" sanitize="never" value="#{outController.html}"/> Text in red, green and blue.

Probably you will find no colors here. In that case, the CSP in the browser protectes against inline style. Further information about CSP in Tobago can be found in the security section.

© 2005-2023 Apache Software Foundation, Licensed under the Apache License, Version 2.0.