Is there a way to set my component focus after an function call to an other component with Primefaces RequestContex?
i tried:
RequestContex.getCurrentIns
Looks like you're under a couple of misconceptions here:
That you can execute Java code in RequestContext
API.
RequestContext.getCurrentInstance().execute("(((InputText) event.getComponent()).getWidgetVar()).Focus();");
You can't. The code above will not work. execute
is built for JavaScript only.
The function name you're looking for is focus()
. JS is case-sensitive. So Focus <> focus
. So I think what you should have there is
RequestContext.getCurrentInstance().execute("yourClientSideId.focus();");
Where yourClientSideId
should correspond to the widgetVar
attribute of the component you're interested in. I'm not sure what the PF
object you're referencing in your code is supposed to be. I've never seen it. Perhaps you meant the PrimeFaces
object?
In the event of failure of the above, you could always use the scrollTo
method on RequestContext
:
RequestContext.getCurrentInstance().scrollTo("yourComponentWidgetVar");