Output <tc: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

Escape

If the given string to the outputfield 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.
<?xml version="1.0" encoding="UTF-8"?> <!-- * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. --> <ui:composition template="/main.xhtml" xmlns="http://www.w3.org/1999/xhtml" xmlns:tc="http://myfaces.apache.org/tobago/component" xmlns:ui="http://java.sun.com/jsf/facelets"> <ui:param name="title" value="#{demoBundle.out} &lt;tc:out&gt;"/> <p>The <code class="language-markup">&lt;tc:out/></code> display an outputtext combined with a label.</p> <tc:link label="Tag Library Documentation" image="#{request.contextPath}/image/feather-leaf.png" link="#{demoBundle.tagDocUrl}/#{apiController.currentRelease}/tld/tc/out.html"/> <tc:section label="Basics"> <p>To put a label in front of a outputtext, use the <code>label</code> attribute.</p> <pre><code class="language-markup">&lt;tc:out label="Output" value="Some Text"/&gt;</code></pre> <tc:out id="o1" label="Output" value="Some Text"/> <tc:out id="o2" value="Output without a label"/> <tc:section label="Skip with compact"> <p>If using <code>labelLayout="skip"</code> there is still a tag surrounding the output text.</p> <tc:out id="outSkip" value="This text is rendered by tc:out with labelLayout=skip." labelLayout="skip"/> <p>Set <code>compact="true"</code> to remove the surrounding tag as well.</p> <tc:out id="outSkipCompact" value="This text is rendered by tc:out with labelLayout=skip and compact=true." labelLayout="skip" plain="true"/> </tc:section> </tc:section> <tc:section label="Markups"> <tc:segmentLayout extraSmall="4seg"> <tc:out value="thin" markup="thin"/> <tc:out value="normal"/> <tc:out value="bold" markup="bold"/> <tc:out value="italic" markup="italic"/> </tc:segmentLayout> <tc:segmentLayout extraSmall="4seg"> <tc:out value="primary" markup="primary"/> <tc:out value="secondary" markup="secondary"/> <tc:out value="success" markup="success"/> <tc:out value="danger" markup="danger"/> <tc:out value="warning" markup="warning"/> <tc:out value="info" markup="info"/> <tc:out value="light" markup="light"/> <tc:out value="dark" markup="dark"/> <tc:out value="muted" markup="muted"/> </tc:segmentLayout> </tc:section> <tc:section label="Escape"> <p>If the given string to the outputfield is HTML/XML code, it will be escaped by default. But you can turn it off with the <code>escape</code> attribute.</p> <tc:section label="Escape on (default)"> <pre><code class="language-markup">&lt;tc:out label="Escape on (default)" escape="true" value="\#{outController.html}"/&gt;</code></pre> <tc:out id="o3" label="Escape on (default)" escape="true" value="#{outController.html}"/> </tc:section> <tc:section label="Escape off"> <p>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).</p> <pre><code class="language-markup">&lt;tc:out label="Escape off" escape="false" value="\#{outController.html}"/&gt;</code></pre> <tc:out id="o4" label="Escape off" escape="false" value="#{outController.html}"/> </tc:section> </tc:section> <tc:section label="Sanitize"> <p>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 <code>org.apache.myfaces.tobago.sanitizer.Sanitizer</code>.</p> <p>Sanitzing can be deactivated for a component using the <code>sanitize</code> attribute. But be careful, because of XSS vulnerability.</p> <pre><code class="language-markup">&lt;tc:out label="Sanitize off" escape="false" sanitize="never" value="\#{outController.html}"/&gt;</code></pre> <tc:out id="o5" label="Sanitize off" escape="false" sanitize="never" value="#{outController.html}"/> </tc:section> </ui:composition>