[richfaces-issues] [JBoss JIRA] (RF-13251) FocusManager to support complex components like rich:autocomplete

Lukáš Fryč (JIRA) jira-events at lists.jboss.org
Thu Nov 28 05:18:06 EST 2013


    [ https://issues.jboss.org/browse/RF-13251?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12927304#comment-12927304 ] 

Lukáš Fryč edited comment on RF-13251 at 11/28/13 5:18 AM:
-----------------------------------------------------------

Hey Immo,

you shouldn't try to put focus on input itself, but rather use the component. Focus component itself will determine what to focus inside the target component.

Here is the alghoritm:

1. determine {{focusCandidates}} (that's what FocusManager, focus preserve or others do)
2. look for {{:tabbable}} elements under candidates
3. select first {{:tabbable}} candidate element

If we have similar DOM:

{code}
<div id="autocomplete">
  <input id="autocompleteInput" />
</div>
{code}

you have focus candidate {{autocomplete}} (known on server as a client ID) (step 1),
and you build list of actual candidate elements as {{[ 'autocompleteInput' ]}} (step 2),
and use the first of them: {{autocompleteInput}} (step 3).

See the implementation here:
https://github.com/richfaces/richfaces/blob/master/framework/src/main/resources/META-INF/resources/org.richfaces/misc/focus/focus.js#L77

----

In other words, use 'autocomplete' as a focus ID.

You can access RichFaces client-side log to see what's happening.
                
      was (Author: lfryc):
    Hey Immo,

you shouldn't try to put focus on input itself, but rather use the component. Focus component itself will determine what to focus inside the component.

Here is the alghoritm:

1. determine {{focusCandidates}} (that's what FocusManager, focus preserve or others do)
2. look for {{:tabbable}} elements under candidates
3. select first {{:tabbable}} candidate element

If we have similar DOM:

{code}
<div id="autocomplete">
  <input id="autocompleteInput" />
</div>
{code}

you have focus candidate {{autocomplete}} (known on server as a client ID) (step 1),
and you build list of actual candidate elements as {{[ 'autocompleteInput' ]}} (step 2),
and use the first of them: {{autocompleteInput}} (step 3).

See the implementation here:
https://github.com/richfaces/richfaces/blob/master/framework/src/main/resources/META-INF/resources/org.richfaces/misc/focus/focus.js#L77

----

In other words, use 'autocomplete' as a focus ID.

You can access RichFaces client-side log to see what's happening.
                  
> FocusManager to support complex components like rich:autocomplete
> -----------------------------------------------------------------
>
>                 Key: RF-13251
>                 URL: https://issues.jboss.org/browse/RF-13251
>             Project: RichFaces
>          Issue Type: Feature Request
>      Security Level: Public(Everyone can see) 
>          Components: component-misc
>    Affects Versions: 4.3.4
>            Reporter: Immo Benjes
>            Assignee: Lukáš Fryč
>            Priority: Minor
>              Labels: waiting_on_user
>
> Currently the FocusManager in Richfaces only works on 'simple' UI components like h:inputText or h:selectOneMenu but not on more complex components like rich:autocomplete.
> It would be good if FocusManager could support complex components or 'real' Ids as generated for that page.
> The use case for the support on autocomplete is like this:
> User has to enter multiple 'entities'. A rich:autocomplete is used to select the entity and add it to a list. After each ajax submit the focus gets lost and the user has to manually set the focus back to the autocomplete input field.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira



More information about the richfaces-issues mailing list