Parent Project
Project Documentation

Summary

Tag Name: <tr:selectOneChoice>
Java Class: org.apache.myfaces.trinidad.component.core.input.CoreSelectOneChoice
Component Type: org.apache.myfaces.trinidad.CoreSelectOneChoice
The selectOneChoice component creates a menu-style component, which allows the user to select a single value from a list of items. The selectOneChoice component contains any number of <f:selectItem>, <f:selectItems>, or <tr:selectItem> components, each of which represents an available option that the user may select.

Code Example(s)

<tr:selectOneChoice value="#{bean.aValue}" required="true">
  <f:selectItem itemLabel="Option1" itemValue="1"/>
  <f:selectItem itemLabel="Option1" itemValue="2"/>
  <f:selectItem itemLabel="Option1" itemValue="3"/>
</tr:selectOneChoice>

Supported Client Events for Client Behaviors

  • blur
  • change (default)
  • click
  • dblclick
  • focus
  • keydown
  • keypress
  • keyup
  • mousedown
  • mousemove
  • mouseout
  • mouseover
  • mouseup
  • valueChange

Events

Type Phases Description
javax.faces.event.ValueChangeEvent Process Validations,
Apply Request Values
The valueChange event is delivered when the value attribute is changed.
org.apache.myfaces.trinidad.event.AttributeChangeEvent Invoke Application,
Apply Request Values
Event delivered to describe an attribute change. Attribute change events are not delivered for any programmatic change to a property. They are only delivered when a renderer changes a property without the application's specific request. An example of an attribute change event might include the width of a column that supported client-side resizing.

Supported Facets

Name Description
help This facet should contain field level help.

Attributes

Name Type Supports EL? Description
accessKey char Yes Character used to gain quick access to the form element specified by the for, if set (or this component itself, if it is a "non-simple" form element). For accessibility reasons, this functionality is not supported in screen reader mode. If the same access key appears in multiple locations in the same page of output, the rendering user agent will cycle among the elements accessed by the similar keys.

This attribute is sometimes referred to as the "mnemonic".

attributeChangeListener javax.el.MethodExpression Only EL a method reference to an attribute change listener. Attribute change events are not delivered for any programmatic change to a property. They are only delivered when a renderer changes a property without the application's specific request. An example of an attribute change events might include the width of a column that supported client-side resizing.
autoSubmit boolean Yes Default Value: false

If set to TRUE on a form element, the component will automatically submit the enclosing form when an appropriate action takes place (a click, text change, etc.).
binding org.apache.myfaces.trinidad.component.core.input.CoreSelectOneChoice Only EL an EL reference that will store the component instance on a bean. This can be used to give programmatic access to a component from a backing bean, or to move creation of the component to a backing bean.
contentStyle String Yes the CSS styles to attach to the content of the component. For example, you can set the width of that portion to 100 pixels by setting this attribute to "width: 100px".
converter javax.faces.convert.Converter Yes a converter object
disabled boolean Yes Default Value: false

whether the element is disabled.
id String No the identifier for the component. Every component may be named by a component identifier that must conform to the following rules:
  • They must start with a letter (as defined by the Character.isLetter() method) or underscore ( _ ).
  • Subsequent characters must be letters (as defined by the Character.isLetter() method), digits as defined by the Character.isDigit() method, dashes ( - ), or underscores ( _ ). To minimize the size of responses generated by JavaServer Faces, it is recommended that component identifiers be as short as possible. If a component has been given an identifier, it must be unique in the namespace of the closest ancestor to that component that is a NamingContainer (if any).
immediate boolean Yes Default Value: false

whether the value is converted and validated immediately in the Apply Request Values phase, or is handled in the Process Validators phase, the default. By default, values are converted and validated together in the Process Validators phase. However, if you need access to the value of a component during Apply Request Values - for example, if you need to get the value from an actionListener on an immediate commandButton - then setting this to "immediate" makes that possible.
inlineStyle String Yes the CSS styles to use for this component.
label String Yes the label of the bean.
labelAndAccessKey String Yes An attribute that will simultaneously set both the "value" and "accessKey" attributes from a single value, using conventional ampersand ('&') notation.

For example, setting this attribute to "L&amp;abel" will set the label to "Label" and the access key to 'a'.

onblur String Yes the event handler for the component losing the focus.
Not supported on the following agents: pda
onchange String Yes event handler for when the value is changed.
onclick String Yes an onclick Javascript handler.
ondblclick String Yes an ondblclick Javascript handler.
onfocus String Yes the event handler for the component gaining the focus.
Not supported on the following agents: pda
onkeydown String Yes an onkeydown Javascript handler.
onkeypress String Yes an onkeypress Javascript handler.
onkeyup String Yes an onkeyup Javascript handler.
onmousedown String Yes an onmousedown Javascript handler.
onmousemove String Yes an onmousemove Javascript handler.
onmouseout String Yes an onmouseout Javascript handler.
onmouseover String Yes an onmouseover Javascript handler.
onmouseup String Yes an onmouseup Javascript handler.
partialTriggers String[] Yes the IDs of the components that should trigger a partial update.

This component will listen on the trigger components. If one of the trigger components receives an event that will cause it to update in some way, this component will request to be updated too.

Separate multiple triggers with a space. e.g., partialTriggers="cmp1 cmp2"

Identifiers must account for NamingContainers. You can use a single colon to start the search from the root, or use multiple colons to move up through the NamingContainer. For example, "::" will pop out of this component's naming container (it pops out of itself if it is a naming container), ":::" will pop out of two naming containers, etc. The search for the partialTrigger begins from there. e.g., partialTriggers=":::commandButton1" the search begins for the component with id = commandButton1 after popping out of two naming containers relative to this component. To go into naming containers, you separate the naming containers with ':', e.g.,partialTriggers= "nc1:nc2:nc3:componentId".

readOnly boolean Yes Default Value: false

whether the element is read-only.
rendered boolean Yes Default Value: true

whether the component is rendered. When set to false, no output will be delivered for this component (the component will not in any way be rendered, and cannot be made visible on the client). If you want to change a component's rendered attribute from false to true using PPR, set the partialTrigger attribute of its parent component so the parent refreshes and in turn will render this component.
required boolean Yes Default Value: false

whether a non-null, non-empty value must be entered. If false, validators will not be executed when the value is null or empty.
requiredMessageDetail String Yes the message to be displayed, if 'required' validation fails.

Parameters:

  • {0} the label that identifies the component
shortDesc String Yes The short description of the component. This text is commonly used by user agents to display tooltip help text.
showRequired boolean Yes Default Value: false

whether the associated control displays a visual indication of required user input. If a "required" attribute is also present, both the "required" attribute and the "showRequired" attribute must be false for the visual indication not to be displayed.
simple boolean Yes Default Value: false

a boolean value that controls whether the component provides label and message support; when set to "true", the component will not display messaging support or the label (these attributes may be ignored: label, labelAndAccessKey, accessKey, showRequired, tip), and may use simpler layout primitives
styleClass String Yes a CSS style class to use for this component.
unselectedLabel String Yes The label for the option that represents a value of null, meaning nothing is selected. If unselectedLabel is not set and if the component does not have a selected value, then an option with an empty string as the label and value is rendered as the first option in the choice box (if there isn't an empty option already defined). Once an option has been successfully selected, and if unselectedLabel is not set, then the empty option will not be rendered.
validator javax.faces.el.MethodBinding Only EL a method reference to a validator method
value Object Yes the value of the component. If the EL binding for the "value" points to a bean property with a getter but no setter, and this is an editable component, the component will be rendered in read-only mode.
valueChangeListener javax.faces.el.MethodBinding Only EL a method reference to a value change listener
valuePassThru boolean Yes Default Value: false

whether or not the values are passed through to the client. When valuePassThru is false the value and the options' values are converted to indexes before being sent to the client. Therefore, when valuePassThru is false, there is no need to write your own converter when you are using custom Objects as your values and/or options. If you need to know the actual values on the client-side, then you can set valuePassThru to true. This will pass the values through to the client, using your custom converter if it is available; a custom converter is needed if you are using custom objects. The default is false.