View Source

h2. Overview
_Since 4.0_

You can use the _icecore:focusManager_ tag to manage where focus will be applied on page load.

{tip}See the ICEfaces Showcase [Live Demo|http://icefaces-showcase.icesoft.org/showcase.jsf?grp=aceMenu&exp=focusManagerBean] of this component, complete with source code.{tip}

The focus manager provides the following automatic focus setting features when it is included inside a form component:

* The first visible (enabled) input element in the form has focus set on it initially.
* Alternatively, if there is an invalid component in the form (failed validation), the first visible (enabled) invalid component will receive focus instead.
* The application also can specify a component to have focus set on it via the "for" attribute.

h2. Getting Started

To use the _icecore:focusManager_ tag, first declare the core namespace:

{panel}
{code:html|borderStyle=dashed}
<html ... xmlns:icecore="http://www.icefaces.org/icefaces/core">
{code}
{panel}

Then add the tag to your page enclosing the components that you want to have the focus managed:

{panel}
{code:xml|borderStyle=dashed}
<h:body>
...
<icecore:focusManager>
....
<h:form>
<h:inputText .../>
<h:inputText .../>
....
....
<ace:autoCompleteEntry ..../>
</h:form>
....
</icecore:focusManager>
...
</h:body>
{code}
{panel}

Example using the "for" attribute:

{code:xml|borderStyle=dashed}
<h:form id="form">
...
<icecore:focusManager for="A">
<h:inputText .../>
<h:inputText id="A" .../>
....
....
<ace:autoCompleteEntry ..../>
</icecore:focusManager>
...
</h:form>
{code}

h2. Attributes

{tip:title=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|http://res.icesoft.org/docs/v4_latest/core/comps/tld/icecore/focusManager.html].{tip}

{panel}
*for* Use this attribute to specify the ID of the component that will receive focus.
{panel}