For many components, a label attribute is available, which place a label in front of the according component. With the labelLayout you can adjust this label. The following examples use an inputfield to show, how this works.
label
labelLayout
Tag Library Documentation: <tc:in/> | <tc:flowLayout/> | <tc:flexLayout/> | <tc:segmentLayout/>
If the labelLayout is not set, the value is 'flexLeft' by default.
<tc:in label="Input"/>
The value 'none' has the same effect as just not set the label attribute.
<tc:in label="Input" labelLayout="none"/>
The labelLayout is set to 'top'.
<tc:in label="Input" labelLayout="top"/>
<tc:in label="Input" labelLayout="flowLeft"/> <tc:in label="Input" labelLayout="flowRight"/>
<tc:in label="Input" labelLayout="flexLeft"/> <tc:in label="Input" labelLayout="flexRight"/>
The segment layout is divided in two columns. The right one is three times bigger. The 'segmentLeft' and 'segmentRight' put the label in the left or in the right column.
<tc:segmentLayout medium="3seg 9seg"> <tc:in label="Input" labelLayout="segmentLeft"/> <tc:in label="Input" labelLayout="segmentRight"/> </tc:segmentLayout>
<?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.labeled_layout}"/> <p>For many components, a <code>label</code> attribute is available, which place a label in front of the according component. With the <code>labelLayout</code> you can adjust this label. The following examples use an inputfield to show, how this works.</p> <p>Tag Library Documentation: <tc:link label="<tc:in/>" image="#{request.contextPath}/image/feather-leaf.png" link="#{demoBundle.tagDocUrl}/#{apiController.currentRelease}/tld/tc/in.html"/> | <tc:link label="<tc:flowLayout/>" image="#{request.contextPath}/image/feather-leaf.png" link="#{demoBundle.tagDocUrl}/#{apiController.currentRelease}/tld/tc/flowLayout.html"/> | <tc:link label="<tc:flexLayout/>" image="#{request.contextPath}/image/feather-leaf.png" link="#{demoBundle.tagDocUrl}/#{apiController.currentRelease}/tld/tc/flexLayout.html"/> | <tc:link label="<tc:segmentLayout/>" image="#{request.contextPath}/image/feather-leaf.png" link="#{demoBundle.tagDocUrl}/#{apiController.currentRelease}/tld/tc/segmentLayout.html"/></p> <tc:section label="Basics"> <tc:section label="Default value"> <p>If the <code>labelLayout</code> is not set, the value is 'flexLeft' by default.</p> <pre><code class="language-markup"><tc:in label="Input"/></code></pre> <tc:in label="Input"/> </tc:section> <tc:section label="No label"> <p>The value 'none' has the same effect as just not set the <code>label</code> attribute.</p> <pre><code class="language-markup"><tc:in label="Input" labelLayout="none"/></code></pre> <tc:in label="Input" labelLayout="none"/> </tc:section> <tc:section label="Label on top"> <p>The <code>labelLayout</code> is set to 'top'.</p> <pre><code class="language-markup"><tc:in label="Input" labelLayout="top"/></code></pre> <tc:in label="Input" labelLayout="top"/> </tc:section> </tc:section> <tc:section label="#{demoBundle.flow_layout}"> <pre><code class="language-markup"><tc:in label="Input" labelLayout="flowLeft"/> <tc:in label="Input" labelLayout="flowRight"/></code></pre> <tc:in label="Input" labelLayout="flowLeft"/> <tc:in label="Input" labelLayout="flowRight"/> </tc:section> <tc:section label="#{demoBundle.flex_layout}"> <pre><code class="language-markup"><tc:in label="Input" labelLayout="flexLeft"/> <tc:in label="Input" labelLayout="flexRight"/></code></pre> <tc:in label="Input" labelLayout="flexLeft"/> <tc:in label="Input" labelLayout="flexRight"/> </tc:section> <tc:section label="#{demoBundle.segment_layout}"> <p>The segment layout is divided in two columns. The right one is three times bigger. The 'segmentLeft' and 'segmentRight' put the label in the left or in the right column.</p> <pre><code class="language-markup"><tc:segmentLayout medium="3seg 9seg"> <tc:in label="Input" labelLayout="segmentLeft"/> <tc:in label="Input" labelLayout="segmentRight"/> </tc:segmentLayout></code></pre> <tc:segmentLayout medium="3seg 9seg"> <tc:in label="Input" labelLayout="segmentLeft"/> <tc:in label="Input" labelLayout="segmentRight"/> </tc:segmentLayout> </tc:section> </ui:composition>