Formatting

Use the EL functions from tc:format1 to tc:format9 to replace up to 9 variables in a given internationalized text. This work like in java.text.MessageFormat.

Format 1

The message format is: "The equatorial radius of the sun is {0} km."

<tc:out value="#{tc:format1(demoBundle.format1, 695700)}"/>
The equatorial radius of the sun is 695,700 km.

Format 3

The message format is: "The temperature of the sun is {0} K on the surface, but {1} K in the center and {2} K in the corona."

<tc:out value="#{tc:format3(demoBundle.format3, 5800, 15700000, 5000000)}"/>
The temperature of the sun is 5,800 K on the surface, but 15,700,000 K in the center and 5,000,000 K in the corona.

Format 9

The message format is: "Just reordering: {4} - {1} - {6} - {8} - {5} - {3} - {0} - {7} - {2}"

<tc:out value="#{tc:format9(demoBundle.format9, 0, 1, 2, 3, 4, 5, 6, 7, 8)}"/>
Just reordering: 4 - 1 - 6 - 8 - 5 - 3 - 0 - 7 - 2

UpperCase

You may also use the fn: function library for string manipulation.

<tc:out value="#{fn:toUpperCase('uppercase')}"/>
UPPERCASE
<?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" xmlns:fn="http://java.sun.com/jsp/jstl/functions"> <ui:param name="title" value="#{demoBundle.format}"/> <p>Use the EL functions from <code>tc:format1</code> to <code>tc:format9</code> to replace up to 9 variables in a given internationalized text. This work like in <tc:link label="java.text.MessageFormat" link="https://docs.oracle.com/javase/6/docs/api/java/text/MessageFormat.html"/>.</p> <tc:section label="Format 1"> <p>The message format is: "#{demoBundle.format1}"</p> <pre><code class="language-markup">&lt;tc:out value="\#{tc:format1(demoBundle.format1, 695700)}"/></code></pre> <tc:out id="o1" value="#{tc:format1(demoBundle.format1, 695700)}"/> </tc:section> <tc:section label="Format 3"> <p>The message format is: "#{demoBundle.format3}"</p> <pre><code class="language-markup">&lt;tc:out value="\#{tc:format3(demoBundle.format3, 5800, 15700000, 5000000)}"/></code></pre> <tc:out id="o2" value="#{tc:format3(demoBundle.format3, 5800, 15700000, 5000000)}"/> </tc:section> <tc:section label="Format 9"> <p>The message format is: "#{demoBundle.format9}"</p> <pre><code class="language-markup">&lt;tc:out value="\#{tc:format9(demoBundle.format9, 0, 1, 2, 3, 4, 5, 6, 7, 8)}"/></code></pre> <tc:out id="o3" value="#{tc:format9(demoBundle.format9, 0, 1, 2, 3, 4, 5, 6, 7, 8)}"/> </tc:section> <tc:section label="UpperCase"> <p>You may also use the <code>fn:</code> function library for string manipulation.</p> <pre><code class="language-markup">&lt;tc:out value="\#{fn:toUpperCase('uppercase')}"/></code></pre> <tc:out id="o4" value="#{fn:toUpperCase('uppercase')}"/> </tc:section> </ui:composition>