We need to recall what we learned about attribute data types and the use of OGNL expressions in attribute values.
If the data type is String, then the attribute value will be interpreted as a string literal. This means that it won’t be evaluated as an OGNL expression unless you force that evaluation with the %{ expression } notation. On the other hand, all non-String data types will be automatically evaluated as OGNL expressions. Generally, this means that you won‘t have to use the formal OGNL expression brackets often because you’ll typically feed literal strings to the String attributes and OGNL expressions to the non-String data types.
序号 | Attribute | Theme | Data type | Description |
---|---|---|---|---|
1 | name | simple | String | Sets name attribute of the form input element. Also propagates to the value attribute of the component, if that attribute isn‘t set manually. The name itself is used by the component to target a property on the ValueStack as destination for the posted request parameter value. |
2 | value | simple | Object | OGNL expression pointing to ValueStack property used to set the value of the form input element for pre-population. Defaults to the name attribute. |
3 | key | simple | String | Pulls localized label from ResouceBundle, and can propagate to name attribute, and thus value attribute. |
4 | label | XHTML | String | Create an HTML label for the component. Not needed if setting using key attribute and localized text. |
5 | labelPosition | XHTML | String | Location of the element label: left or top. |
6 | required | XHTML | Boolean | If true, an asterisk appears next to the label indicating the field is required. By default, the value is true if a field-level validator is mapped to the field indicated in the name attribute. |
7 | id | simple | String | HTML id attribute. Components will create a unique ID if one isn‘t specified. IDs are useful for both Javascript and CSS. |
8 | cssClass | simple | String | HTML class attribute, for CSS. |
9 | cssStyle | simple | String | HTML style attribute, for CSS. |
10 | disabled | simple | Boolean | HTML disabled attribute. |
11 | tabindex | simple | String | HTML tabindex attribute. |
12 | theme | N/A | String | Theme under which component should be rendered, such as xhtml, css_xhtml, ajax, simple. Default value is xhtml, set in default.properties. |
13 | templateDir | N/A | String | Used to override the default directory name from which templates will be retrived. |
14 | template | N/A | String | Template to look up to render the UI tag. All UI tags have a default template(except the component tag), but the template can be overridden. |
In addition to these attributes, the components also support the common JavaScript event handler attributes, such as onclick and onchange. Basically, the components support any HTML attribute you’ll want to set. In common tag usage, you’ll typically only use a few of these attributes, such as name, key, label, and value.