Re: Setting focus on input fields

From: Jason Lee <>
Date: Fri, 28 Mar 2008 14:05:39 -0500

On Fri, Mar 28, 2008 at 1:54 PM, Doug Donahue <>

> I guess one benefit to the "focus" attribute would be that it would
> only have scope to the child elements of itself. where as the
> "tabindex" I believe is for the entire page that is rendered.
> I think that the "focus" attribute it would be a good thing to have
> for JSF 2.0.

Would a custom component help with that? Something like this:

<foo:focus element="form1:firstName" /> (for a specific element)
<foo:focus /> (to grab the element on the page with the lowest tab index)

This might be nice too:
<h:inputText><foo:focus/></h:inputText> (with the last one winning, if the
page author has several for some reason)

That wouldn't be too hard to cobble together, I wouldn't think. If that
doesn't sound too dumb, I'd be happy to give that a whirl (API suggestions,
are, or course, highly desired :).

Jason Lee, SCJP
Software Architect -- Objectstream, Inc.
Mojarra and Mojarra Scales Dev Team