-
15. Re: FocusManager proposition
jbalunas May 17, 2010 9:55 AM (in response to blabno)I can't wait to try this out!!
We need to get 4.0 Alpha2 out, and then I'll have some more time to look at this. I like what I'm seeing thought, and that idea !!
-Jay
-
16. FocusManager proposition
blabno Mar 18, 2011 4:37 AM (in response to jbalunas)Focus component has undergone heavy lifting. It was tested in real life app where lack of several features has been found. Those features are now ready for you:
- delay focus (usefull when focusing controls inside modal panel)
- override individual control's clientId or priority and still use only one focus component
Check out example 6 and 7 of online demo: http://bernard.labno.pl/focus-sample/.
-
17. FocusManager proposition
jbalunas Mar 18, 2011 8:26 AM (in response to blabno)Now that RichFaces 4.0.0.Final is nearly out - I want to start talking about getting this component into the 4.1 ( /trunk )!
-
18. Re: FocusManager proposition
ealonso04 Jun 21, 2012 4:02 PM (in response to blabno)Hi guys!
Im new to Richfaces, can you tell me how can I include or add this custom tag in order to use it in my richfaces project?
I hope you can help me, Thanks in advance! = )
-
19. Re: FocusManager proposition
ppitonak Jun 22, 2012 4:06 AM (in response to ealonso04)Hi Ernesto,
this component is in RichFaces sandbox repository [1] where you can find also a demo. To start using it, you just need to define this Maven dependency:
<dependency> <groupId>org.richfaces.sandbox.ui.focus</groupId> <artifactId>focus-ui</artifactId> <version>${project.version}</version> </dependency>
You also need to use JBoss Snapshots repository [2].
Regards,
Palo
[1] https://github.com/richfaces/sandbox/tree/develop/focus
[2] https://repository.jboss.org/nexus/content/repositories/snapshots/
-
20. Re: FocusManager proposition
lfryc Nov 20, 2012 3:57 AM (in response to blabno)Hey guys,
I did extensive review of what has been done prior art - collected information from this thread, issue tracker as well as third-party implementations.
I have also considered collected requirements and I think original Bernard's implementation can be re-used, but with modifications.
Requirements
and as I result, I collected following requirements for Focus components:
- component scoped + AJAX-aware
- works on the level of all inputs inside given component during both partial and full page request
- can be placed either by h:body, h:form or any container component
- focus is applied after each rendering of focusManager once document is ready or after AJAX request
- ajaxRendererd="true" by default
- validation-aware
- for setting up focus for first invalid input component (enabled by default)
- last focused element should not lose focus
- (optional mode) focus should be preserved after full/ajax request (for given component)
- tabindex aware (replacing priority attribute from p:focus from Bernard)
- the focus should respect tabindex attribute (particularly in case of validation-aware mode)
- delayed focus
- expose API for setting up focus to input inside DOM which has not been initially visible (e.g. modal panel)
- non-JSF input / multi-component support
- @selector attribute
- support for selectOneRadio's options
- via @selector attribute
- via @selector attribute
- programatic API for setting focus to component
Btw I would like to emphasize difference between Bernard's components and my proposal:
- reworked user API to align with core component suite
- using tabindex instead of priority
- added preservation of input focus
- no need to implicitly specify focus for components
User API
From the requirements, there is following proposal for user API:
Focus will be applied for all forms (either full page submits or AJAX requests).
The currently selected component will be focused after full/ajax update.
<h:body> <r:focus preserve="true" /> ... </h:body>
Focus will ignore results of validation, inputB will be always focused after initial page request (nothing will be selected after AJAX request):
<h:form> <r:focus validationAware="false" ajaxRendered="false" /> <h:inputText id="inputA" tabindex="3" /> <h:inputText id="inputB" tabindex="2" /> </h:form>
First input in modal panel will be focused once the modal is shown:
<r:modalPanel id="modal" onshow="#{r:component('modalFocusManager')}.applyFocus()"> <r:focus name="modalFocusManager" delayed="true" /> ... </r:modalPanel>
When r:focus placed in input component, its focus will be preserved no matter what (ignoring r:focusManager settings).
Not implemented in 4.3 (you can use FocusManager service instead)
<h:inputText> <r:focus preserve="true" /> </h:inputText>
Non-JSF Input sample:
<input id="htmlInput" /> <r:focus selector="#htmlInput" />
Additionally, there should be API for implicitly setting the component which should obtain focus (both full and partial requests):ServiceTracker.getService(FocusManager.class).focus("componentId");
Feedback
I would appreciate any feedback on what you think about the user API and requirements!
- component scoped + AJAX-aware
-
-
22. Re: FocusManager proposition
ppitonak Nov 6, 2012 4:12 AM (in response to lfryc)Lukas, it looks good.
-
23. Re: FocusManager proposition
lfryc Nov 13, 2012 3:03 AM (in response to blabno)Okay, during implementation we found some issues:
- FocusManager needs to be form-oriented
- otherwise you can't decide what focus should be applied at the end
- so there can be just one non-delayed form-wide focus
I have decided don't implement r:focus right now, my proposal is to:
- rename r:focusManager to r:focus
- implement r:focus as nestable to another components later, if required
- it would allow rewriting per-component settings
- use FocusManager service as a workaround for enforcing focus to particular component
- it would allow rewriting per-component settings
- FocusManager needs to be form-oriented
-
24. Re: FocusManager proposition
lfryc Nov 20, 2012 3:59 AM (in response to lfryc)I have updated last proposal ^ so that it reflects current implementation state: