Focus an inputText when opening dialog in primefaces

≡放荡痞女 提交于 2019-12-12 04:45:11

问题


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 ?

来源:https://stackoverflow.com/questions/15583674/focus-an-inputtext-when-opening-dialog-in-primefaces

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!