dev@javaserverfaces.java.net

Re: Setting focus on input fields

From: Mike Kienenberger <mkienenb_at_gmail.com>
Date: Wed, 16 Apr 2008 11:51:04 -0400

For what it's worth, Apache Tomahawk implemented it as described here,
as a separate component:

http://myfaces.apache.org/sandbox/focus.html


<h:inputText id="textfield" value="#{bean.value}" />
<s:focus id="focus" for="textfield" />

or

<s:focus id="focus" for="#{bean.focusedComponentId}" />



On 4/10/08, Jim Driscoll <Jim.Driscoll_at_sun.com> wrote:
> Interesting - so focus becomes part of the server managed state.
>
> I can see a place for that, but it seems as complex as you'd expect for a
> sophisticated management of shared state. But the common case is:
>
> <webuijsf:body focus="form1:textTest3">
>
> Which is pretty darn simple. I like it.
>
> Jim
>
>
> Ken Paulsen wrote:
>
> >
> > Hi everyone,
> >
> > I'm sorry I'm late to reading this thread. The Woodstock team has been
> dealing with focus behavior since before they started writing JSF
> components. The Woodstock component set handles the focus behavior as
> described here:
> >
> > https://woodstock.dev.java.net/TN-Focus-Behavior.htm
> >
> > Perhaps their experience with this topic is of value to this conversation.
> >
> > Thanks,
> >
> > Ken
> >
> > Jesse Alexander (KSFH 323) wrote:
> >
> > > Hi Jim
> > >
> > > In some way Jason's proposal seems more natural.
> > > For a component that controls which field should have the focus when the
> page is rendered, I see the following possibilities:
> > >
> > > a) <f:view focus=#{some.el.returning.a.id}
> > > focusError=#{el.true.or.false}...>
> > >
> > > b) <h:form focus=#{some.el.returning.a.id}
> > > focusError=#{el.true.or.false}...>
> > >
> > > c) <h:form>
> > > <my:focus ... />
> > > ...
> > > </h:focus>
> > >
> > > d) <v:view>
> > > <my:focus ... >
> > > <h:form>
> > > ...
> > > </h:form>
> > > <h:form>
> > > ...
> > > </h:form>
> > > </my:focus>
> > > </f:view>
> > >
> > > e) <h:form>
> > > <my:focus ...>
> > > ...
> > > </my:focus>
> > > </h:form>
> > >
> > > a) is comfortable, but "reasonably do-able" only through corresponding
> > > spec-changes, necessary if we must suppose that more than one entry
> form per view is the usual thing
> > > b) is comfortable, but "reasonably do-able" only through corresponding
> > > spec-changes
> > > c) is comfortable, does not need a spec change, can be plugged in
> > > d) is comfortable, does not need a spec change, can be plugged in,
> necessary if we must suppose that more than one entry form per view is the
> usual thing
> > > e) feeling a bit "awkward"
> > >
> > > attributes:
> > > - focus: the id, not the client-id, that would be too cumbersome for
> > > developers,
> > > of the field that should receive the focus
> > > - focusError: true|false If true, then the focus should be set on the
> > > first
> > > field that is connected to an error-message shown on the
> > > view
> > >
> > >
> > > guess what: we just did something in that way, choosing c) for JSF 1.2
> > > and Facelets
> > > using some code from the Tomahawk-(sandbox ?)
> > > Which, imho, proves the existing need for such a component
> > >
> > > regards
> > > Alexander
> > >
> > >
> > >
> > >
> > >
> > > > -----Original Message-----
> > > > From: Jim.Driscoll_at_Sun.COM [mailto:Jim.Driscoll_at_Sun.COM] Sent:
> Tuesday, April 08, 2008 6:00 PM
> > > > To: dev_at_javaserverfaces.dev.java.net
> > > > Subject: Re: Setting focus on input fields
> > > >
> > > > Jason Lee wrote:
> > > >
> > > >
> > > > > <foo:focus>
> > > > > <h:inputText></h:inputText>
> > > > > </foo:focus>
> > > > >
> > > > > That would be pretty simple.
> > > > >
> > > > >
> > > > Yes, that would be very easy to do. But it seems the opposite of what
> I would expect - and thus ugly.
> > > >
> > > > Am I the only one who feels this way?
> > > >
> > > > Jim
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail:
> dev-unsubscribe_at_javaserverfaces.dev.java.net
> > > > For additional commands, e-mail:
> dev-help_at_javaserverfaces.dev.java.net
> > > >
> > > >
> > > >
> > > >
> > >
> > >
> ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> dev-unsubscribe_at_javaserverfaces.dev.java.net
> > > For additional commands, e-mail:
> dev-help_at_javaserverfaces.dev.java.net
> > >
> > >
> > >
> >
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> dev-unsubscribe_at_javaserverfaces.dev.java.net For additional
> commands, e-mail: dev-help_at_javaserverfaces.dev.java.net
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> dev-unsubscribe_at_javaserverfaces.dev.java.net
> For additional commands, e-mail:
> dev-help_at_javaserverfaces.dev.java.net
>
>