dev@javaserverfaces.java.net

Re: Setting focus on input fields

From: Jacob Hookom <jacob_at_hookom.net>
Date: Fri, 28 Mar 2008 15:21:46 -0500

I agree that it'd be most correct to have it on f:view such that other
display technologies can implement that assertion without being tied to
'html' forms. Anything else would have to be 'last wins'. Putting it
on the h:form would probably be my last choice over putting it on the
input field itself such that it's a boolean evaluation which can be
supported for form elements in iterative contexts.

Doug Donahue wrote:
>
> Would there ever be a need/want to be able to focus on a given input
> element within one form, but also have the ability to have the focus
> for another form set to one of it's child elements on the same page?
>
> Just taking your example of "focus=idname attribute to the f:view
> tag", and using it as an attribute on any element that can have a
> child input elements.
>
> <f:view focus="form_2">
> <h:form id="form_1" focus="text3">
> <h:inputText id="text1" value="value1"/>
> <h:inputText id="text2" value="value2"/>
> <h:inputText id="text3" value="value3"/>
> </h:form>
>
> <h:form id="form_2" focus="text2">
> <h:inputText id="text1" value="value1"/>
> <h:inputText id="text2" value="value2"/>
> <h:inputText id="text3" value="value3"/>
> </h:form>
> </f:view>
>
> Just a thought, might be more then anyone would ever need.
> Dougd
>
>
>
> Jim Driscoll wrote:
>> I thought about adding a "focus" attribute - but the problem with
>> that is that if you have two focus=true attributes, what do you do?
>> (Yes, we could specify first-come, first served, but that would lead
>> to less readable code, and occasionally surprising results).
>>
>> The problem with using the lowest tab index, is that sometimes you
>> don't want a focus, even if you want a tab order.
>>
>> How about a focus=idname attribute to the f:view tag?
>>
>> Jim
>>
>> Doug Donahue wrote:
>>> That is strange, I just tested it and sure enough it does not work
>>> that way.
>>>
>>> Would it be safe to have the lowest "tabindex" of an input
>>> element take the focus by default? Or is there an additional benefit
>>> to have a "focus" attribute on any parent that can have input elements?
>>>
>>> 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.
>>>
>>> Doug Donahue
>>>
>>> Jacob Hookom wrote:
>>>> I thought the same thing, but documentation/forums online say that
>>>> this will not work
>>>>
>>>> Doug Donahue wrote:
>>>>> Jim;
>>>>>
>>>>> Would the "tabindex" attribute on the input element do the same
>>>>> thing?
>>>>>
>>>>> example:
>>>>> <h:inputText id="fname" label="First Name" tabindex="0"/>
>>>>>
>>>>> Would the focus default to the lowest tabindex?
>>>>>
>>>>> Dougd
>>>>>
>>>>>
>>>>>
>>>>> Jim Driscoll wrote:
>>>>>> How about this for a RFI on the API - setting focus on an input
>>>>>> field.
>>>>>>
>>>>>> Right now, if I understand correctly, you end up coding in
>>>>>> javascript...
>>>>>>
>>>>>> http://forum.java.sun.com/thread.jspa?threadID=651739
>>>>>>
>>>>>> Thoughts? It's a not uncommon request. It would seem a shame to
>>>>>> have to intermingle javascript with your page for such a common
>>>>>> task.
>>>>>>
>>>>>> 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
>>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>
>