options

options

Render a Collection of Select Options

Renders a set of HTML <option> elements, representing possible choices for a <select> element. This tag can be used multiple times within a single <html:select> element, either in conjunction with or instead of one or more <html:option> or <html:optionsCollection> elements.

This tag operates in one of two major modes, depending on whether or not the collection attribute is specified. If the collection attribute is included, the following rules apply:

  • The collection attribute is interpreted as the name of a JSP bean, in some scope, that itself represents a collection of individual beans, one per option value to be rendered.
  • The property attribute is interpreted as the name of a property of the individual beans included in the collection, and is used to retrieve the value that will be returned to the server if this option is selected.
  • The labelProperty attribute is interpreted as the name of a property of the individual beans included in the collection, and is used to retrieve the label that will be displayed to the user for this option. If the labelProperty attribute is not specified, the property named by the property attribute will be used to select both the value returned to the server and the label displayed to the user for this option.

If the collection attribute is not specified, the rules described in the remainder of this section apply.

The collection of values actually selected depends on the presence or absence of the name and property attributes. The following combinations are allowed:

  • Only name is specified - The value of this attribute is the name of a JSP bean in some scope that is the collection.
  • Only property is specified - The value of this attribute is the name of a property of the ActionForm bean associated with our form, which will return the collection.
  • Both name and property are specified - The value of the name attribute identifies a JSP bean in some scope. The value of the property attribute is the name of some property of that bean which will return the collection.

The collection of labels displayed to the user can be the same as the option values themselves, or can be different, depending on the presence or absence of the labelName and labelProperty attributes. If this feature is used, the collection of labels must contain the same number of elements as the corresponding collection of values. The following combinations are allowed:

  • Neither labelName nor labelProperty is specified - The labels will be the same as the option values themselves.
  • Only labelName is specified - The value of this attribute is the name of a JSP bean in some scope that is the collection.
  • Only labelProperty is specified - The value of this attribute is the name of a property of the ActionForm bean associated with our form, which will return the collection.
  • Both labelName and labelProperty are specified - The value of the labelName attribute identifies a JSP bean in some scope. The value of the labelProperty attribute is the name of some property of that bean which will return the collection.

Note that this tag does not support a styleId attribute, as it would have to apply the value to all the option elements created by this element, which would mean that more than one id element might have the same value, which the HTML specification says is illegal.

Can contain: empty

options attributes

NameDescriptionType
collectionName of the JSP bean (in some scope) which is itself a Collection of other beans, each of which has properties named by the "property" and "labelProperty" attributes that are used to retrieve the value and label for each option, respectively. String
filterSet to false if you do NOT want the option labels filtered for sensitive characters in HTML. By default, such values are filtered. boolean
labelNameName of the JSP bean (in some scope) containing the collection of labels to be displayed to the user for these options. String
labelPropertyProperty of the form bean, or the bean specified by the labelName attribute, that will return the collection of labels to be displayed to the user for these options. String
nameName of the JSP bean (in some scope) containing the collection of values to be returned to the server for these options. If not specified, the form bean associated with our form is assumed. String
propertyProperty of the form bean, or the bean specified by the name attribute, that will return the collection of values to returned to the server for these options. String
styleCSS styles to be applied to this HTML element. String
styleClassCSS stylesheet class to be applied to this HTML element (renders a "class" attribute). String

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值