SimpleSelectOneMenu

Table of Contents

Overview

Since 3.3

The ace:simpleSelectOneMenu component is simple selection component, similar to the standard h:selectOneMenu, that integrates well with the ACE environment by providing ajax support, ARIA support, label positions, and theming. Option items are defined by the <f:selectItem> tag. If the backing list is javax.faces.model.SelectItem objects the <f:selectItems> tag can be used. If the backing list is not made of SelectItem objects (such as a String[] array), see the Dynamic Items section below for information on how to render those items.

See the ICEfaces Showcase Live Demo of this component, complete with source code.

Getting Started

In its simplest form, an ace:simpleSelectOneMenu component only requires to have some options defined and to bind its value to a property in a backing bean.

<ace:simpleSelectOneMenu value="#{bean.category}">
	<f:selectItem itemValue="a" itemLabel="Category A" />
	<f:selectItem itemValue="b" itemLabel="Category B" />
	<f:selectItem itemValue="c" itemLabel="Category C" />
</ace:simpleSelectOneMenu>

Dynamic Items

As mentioned for a dynamic list not composed of SelectItem objects use a TagHandler (like <c:forEach>) to loop through your list and output individual <f:selectItem> tags. For example, where bean.category is a String[]:

<ace:simpleSelectOneMenu value="#{bean.category}">
    <f:selectItem itemLabel="-Select-"
                  itemValue="None"
                  noSelectionOption="true" />
    <c:forEach items="#{categoryList.items}" var="currentCategory">
        <f:selectItem itemValue="#{currentCategory}"/>
    </c:forEach>
</ace:simpleSelectOneMenu>
Keep in mind you will need the jstl.jar and xmlns:c="http://java.sun.com/jsp/jstl/core" namespace for this approach.

ace:selectMenu vs. ace:simpleSelectOneMenu. The ace:selectMenu and the ace:simpleSelectOneMenu components have the exact same use cases. The main difference is that ace:simpleSelectOneMenu uses the native \<select\> input of the browser, while the ace:selectMenu component builds the menu using divs, spans, and more advanced styling and javascript, so it has a more consistent look and behaviour across browsers. Therefore, ace:simpleSelectOneMenu is lighter and could be better suited for big tables or iterative containers that need to render hundreds or thousands of menus in the same page. It was introduced to be used in place of h:selectOneMenu, because the rendering technique of the latter is not compatible with the delta submit functionality.

Attributes

TagLib Documentation
This section covers attributes involved in the typical use-cases for this component. For reference, the complete taglib documentation for this component is available here.

The value specifies a bean property to which the value of this component is bound to.

Client Behavior Events

valueChange Fired when the value of the menu changes.
blur Fired when the menu loses focus.

JavaScript APIs

Not applicable.

Keyboard and ARIA Support

Full ARIA support. Native <select> element preserved.

The following ARIA roles are supported: select, option.

Labels

This component supports built-in labels. The text specified in the label attribute will be rendered next to the main input field of this component. The position specified by labelPosition will determine where this label is going to be rendered; the possible values are left, right, top, bottom, none and inField (to render the label in the field itself).

Required Indicator

The requiredIndicator attribute specifies the text to be displayed next to the main input field when this component is marked as required. When, this component is not marked as required, then the text specified in the optionalIndicator is going to be rendered. The indicatorPosition attribute determines where this indicator text is going to the rendered; the possible values are left, right, top, bottom, labelLeft, labelRight, and none.

Required Styling

Then this component is marked as required, the main input field receives the CSS class ui-state-required, otherwise, it receives the CSS class ui-state-optional. When this component is marked as invalid by the app, it will be rendered with the CSS class ui-state-error. These CSS classes can be used to add custom styling to this component, in order indicate its current state in a more visual way.

CSS Classes

The following markup represents the basic HTML structure of the component and the CSS classes it uses.

<span class="ui-simpleselectonemenu [user defined classes]">
	<select class="ui-widget ui-inputfield ui-state-default ui-state-optional" style="[user defined styles]">
		<!-- option elements go here... -->
	</select>
</span>

Known Issues

None.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.

© Copyright 2021 ICEsoft Technologies Canada Corp.