I'm actually using JSF with Primefaces, and I have a little trouble with an p:inputText
in a p:dialog
. Indeed I don't know how to give/keep the focus on the inputText when I open my dialog.
Here is my XHTML file :
<body>
...
<p:commandButton id="add-movie-button" value="Add movie" onclick="searchdlg.show()" update="movie-list,text-search" actionListener="#{layout.clearMovieList}"/>
<p:dialog id="search-movie" header="Add movie" widgetVar="searchdlg" modal="true" resizable="false">
<h:outputLabel for="text-search" value="Movie title"/>
<p:inputText id="text-search" autocomplete="true" size="57" value="#{layout.searchedMovie}" style="margin-bottom:10px">
<p:ajax event="keyup" update="movie-list" listener="#{layout.searchMovie}"/>
</p:inputText>
...
</p:dialog>
...
</body>
I've tried this to give the focus on my inputText when keyDown, but it doesn't change anything.
So have you any tips/advice/solution to keep the focus on an InputText in a dialog after its opening ?