label (item)Added by IBM on October 10, 2012 | Version 1 (Original)
|Defines a static text message or an image to display on the form.
If both an image and a text message are defined for the label, the image takes precedence in viewers able to display images.
Available options active, bgcolor, border, borderinfo, fontcolor, fontinfo, format, gradient, help, image, imagemode, itemlocation, itemnext, itemprevious, justify, linespacing, printbgcolor, printfontcolor, printvisible, size, value, visible, xformsenabled, xformsreadonly, xformsrequired, xformsvalid, xforms:output
The following label example shows a value from the XForms data layer combined with a textual label indicating the meaning of the value. The raw data value is formatted using locale-specific currency rules (e.g. $856.07). The data value is determined by a formula provided by the XForms calculate, which is immediately responsive to any user changes to the principal, interest rate, or duration of the loan for which this monthly payment is being calculated. Also, due to the XForms relevant model item property, the label item is invisible until the user enters positive Principal and Duration values.
This is an example of a multiple-line text label:
<xforms:instance xmlns="" id="loan">
calculate="if(instance('rate') > 0,
../Principal * instance('rate')
(1.0 - power(1.0 + instance('rate'), -../Duration)),
../Principal div ../Duration)"
relevant="../Principal > 0 and ../Duration > 0"/>
<xforms:label>Monthly Payment: </xforms:label>
<label sid="RHYME LABEL">
Little Miss Muffet sat on her tuffet,
Eating her curds and whey.
When along came a spider, who sat down beside her,
and frightened Miss Muffet away!
- The text displayed by a label is defined by: the xforms:output option, if given; otherwise the value option.
- To define an image for a label, either use the mediatype="image/*" attribute setting on the xforms:output option or use the XFDL image option.
- To create a multiple line text message, add line breaks to the message text.
- When setting the size option of a label, the height and width of the label will be based on the average character size for the font in use (set with the fontinfo option).
- If you set the width for a label, but not the height, then the label will automatically grow to accommodate the text within the given width. In other words, the text will wrap to fit within the width specified, and the height will increase to accommodate the text.
- If a label's image option points to a data item that does not exist or contains no data, then the label will display its value option instead.
- If a label contains both a value option and an xforms:output option, then the xforms:output overrides the value.
- If a label contains an xforms:output with an xforms:label, the value of the xforms:label is concatenated with the value of the xforms:output (always label first). This allows you to create a decoration for the text that is displayed. For example, you might want your label to read "Total: 200", where the "Total:" is provided by an xforms:label and the "200" is provided by the xforms:output. Note that the xforms:label can only contain text and is not affected by the format option.
- If a label is decorated by an xforms:label, and the justify option it set to right justify, then the value of the label item is right justified but the additional text from the xforms:label remains left justified. This allows you to create space between the xforms:label and the value, as shown:
- If a label contains a suppresslabel option, it prevents the xforms:label from being displayed.
- If a label's image option points to a data item that dynamically changes its mimedata (but not its item sid), then the label will update the image it displays. For information on how to update an image by enclosing a new one, see the data option description.
- Set the image display behavior with the imagemode option.
- The label's background color defaults to being transparent - and thus the label will allow whatever item it is over to show through. For example, it is possible to place a label over another label holding an image. The image will show through the top label.
- Label contents (if text) can be formatted using format flags (see section format).
- The suppresslabel option suppresses the label, so that it is not displayed.