jQuery in Action, 2nd edition*
The moose likes JSF and the fly likes Who has the focus? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Who has the focus?" Watch "Who has the focus?" New topic
Author

Who has the focus?

Wander Soares
Greenhorn

Joined: Jun 18, 2010
Posts: 10
I need to know where the focus of the application is in the server side, i.e., i need to know in the backingbean where the focus is. Any idea?
Cesar Loachamin
Ranch Hand

Joined: Dec 25, 2010
Posts: 90

Could you explain better what you need, because you mean focus ???


When a dream is ending because to come true - OCPJP 6,7. OCE JPA EE6. MCTS
Wander Soares
Greenhorn

Joined: Jun 18, 2010
Posts: 10
What component of the aplication(textboxs,buttons,...) has the focus,i.e, is selected.
Cesar Loachamin
Ranch Hand

Joined: Dec 25, 2010
Posts: 90

Hi wandroide

First above all I suggest you read about the JSF request process lifecycle and understand all phases as soon a request is produced until de page is rendered.
I suggest you also read about the MVC model, wich is where it is based jsf.
That said, when in the client (browser) a component is selected (has the focus) the server does not know anything about this, becuase have not been a request to the server.
One solution to know the component that has the focus in the server is using ajax, you can make a partial request for all components you want when any component has the focus.
If you're using JSF 2.0 you can do it like this:

All the component's between the <f:ajax> and </f:ajax> make a partial request for the onfocus event and call the method especified by the listener attribute
And the method for the listener

I hope this can help you to solve your problem, sorry for my English.

Regards

Cesar
Wander Soares
Greenhorn

Joined: Jun 18, 2010
Posts: 10
Thanks.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Who has the focus?