Form Layout - Label left (default)

Page is ready
Component Demo
 
 
 
 Select to access date picker
 
 Select to access color picker
Variant

Sumary

The panelFormLayout lays out input form controls, such that their labels and fields line up vertically. It supports multiple columns, and also supports a footer facet.
Usually, this component will simply contain labelled Apache Trinidad input components in its main content - these are inputText, inputFile, inputColor, inputListOfValues, inputDate, selectBooleanCheckbox, selectBooleanRadio, selectOneChoice, selectOneListbox, selectOneRadio, selectManyCheckbox, and selectManyListbox. These components must have their "simple" attribute set to false, which is the default, and will cause the labels and fields inside the panelFormLayout to be aligned vertically."/>
When more complex field contents are needed, use a panelLabelAndMessage around the more complex contents needed; see the example below.
Other components can be added to panelFormLayout, but they will not line up with labels and fields automatically, and each will appear on its own row. You can use other panel components - like panelHorizontal - to get some level of layout within a row, but to align contents with the other labels and fields, use panelLabelAndMessage or the "footer" facet.
The panelFormLayout is an example of one of the components that has support for grouping its children components. If you place panelFormLayout child items inside of a group, separators will be drawn around the group of form items if adjacent to other form items (separators won't be drawn at the top if the group is the first item in the column or, similarly, at the bottom if the group is the last item in the column). Grouped panelFormLayout items are kept in the same column of the panelFormLayout even when the assigned rows attribute is set to a value smaller than the number of items in the group. The panelFormLayout component also supports the group component in its footer facet so you can place more than one item in the footer. You can even group footer items one additional time to get separators to appear.

Code samples

JSF Page
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

<!--
    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 xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:tr="http://myfaces.apache.org/trinidad"
                template="/pages/componentDemo.xhtml">

    <ui:define name="demoContent">

        <tr:panelFormLayout rows="8" labelAlignment="start">
            <tr:inputText label="First name" inlineStyle="text-align: left;"/>
            <tr:inputText label="Seccond name"/>
            <tr:inputFile label="Your photo"/>
            <tr:inputDate label="Birth date"/>
            <tr:inputText label="Birth location"/>
            <tr:inputColor label="Favorite color" value="#FFFFFF"/>

            <f:facet name="footer">
                <tr:panelButtonBar inlineStyle="margin-left: 101px;">
                    <tr:commandButton text="Proceed"/>
                    <tr:commandButton text="Cancel"/>
                </tr:panelButtonBar>
            </f:facet>
        </tr:panelFormLayout>

    </ui:define>
</ui:composition>