简体   繁体   中英

Howto set focus in Rich Faces panelBarItem?

Hi I want to set focus on <h:inputText> element whenever rich:panelBarItem is opened. I have:

<rich:panelBar>
   <rich:panelBarItem onenter="setFocus();">
      <h:inputText value="#{bean.value}"/>
   </rich:panelBarItem>   
</rich:panelBar>

it works fine when I open it with mouse click, but does not work first time when first panelBarItem is automatically opened. How should I set focus on first opened panelBarItem? I really would like it to be some event(I could not find) on rich:panerBarItem or rich:panelBar.

You can call your method after page load to set focus to field. Something like

<script>
//call after page loaded
window.onload=setFocus(); 
</script>

or

<body onload="setFocus();">

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM