0 Replies Latest reply on Dec 15, 2008 8:23 AM by Jonathan Moores

    Simulate Click on commandLink

    Jonathan Moores Newbie

      I am wanting to catch an enter key in a input text field and submit my form using the a4j:commandLink defined.

      It works fine with a4j:commandButton but I wanted to use an image in the link.

      Has anyone any ideas?

      Here is what I have at the moment


       <h:panelGroup>
       <h:outputLabel for="originalCode" value="#{msg.text_ref_number}"
       style="padding-right: 10px"/>
       <h:inputText id="originalCode" value="#{searchBean.codeToSearch}"
       onkeydown="return clickSearchButton(event)">
       <a4j:support event="onkeyup" eventsQueue="fooQueue" reRender="searchButton, wrapperPanel"/>
       </h:inputText>
       </h:panelGroup>
       <a4j:commandLink id="searchButton" actionListener="#{searchBean.search}"
       styleClass="#{empty searchBean.codeToSearch ? 'linkButtonDisabled' : 'linkButton positive'}"
       value="#{msg.button_search_text}"
       disabled="#{empty searchBean.codeToSearch}" reRender="wrapperPanel"
       type="submit">
       <h:graphicImage id="search" value="#{msg['image.search.16']}" />
       </a4j:commandLink>
       </h:panelGrid>
      
      


      The following works ok in IE but not in Firefox or Chrome.


      var buttonToClick = document.getElementById('main_view:content_view:searchNumberForm:searchButton');
       if (buttonToClick)
       {
       var buttonNodeName = buttonToClick.nodeName;
       if (buttonNodeName == 'A')
       {
       buttonToClick.onclick();
       return false;
       }
       else
       {
       buttonToClick.focus();
       buttonToClick.click();
       }
       }
      
      


      thanks
      Jon