3 Replies Latest reply on Mar 27, 2008 10:00 AM by Daniel Margreth

    How to set focus the h:commandButton within rich:toolBar

    Thiagu Mariappan Novice

      Hai every one

      I our project we have the search functionality, it is common to all pages.
      So I put the that functionality code within header part (with in the rich:toolbar)
      this is my sample code

      <rich:toolBar
       xmlns="http://www.w3.org/1999/xhtml"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:s="http://jboss.com/products/seam/taglib"
       xmlns:a="https://ajax4jsf.dev.java.net/ajax"
       xmlns:rich="http://richfaces.ajax4jsf.org/rich">
      
      <h:form id="SerachForm">
       <h:inputText id="productname" value="#{homesearch.searchString}" />
       <h:commandButton id="searchbutton" value="Search" action="#{homesearch.doSearch}" type="submit"/>
      </h:form>
      </rich:toolbar>
      

      Here my problem is I can’t set the focus to the search button after enter the search string in my text box.I meant if I enter something in my textbox then I hit the Enter button in my key board , the search function is not invoked by h:commandButton.
      I try with javascript to set the focus to h:commandButton. But the script is ok , I am clear about the event.
      This my script
      document.getElementById('SerachForm:searchbutton').focus();
      

      non of the event support my requirement.
      How resolve this problem .

      By
      Thiagu.m