title: Primefaces Press Enter executes commandButton
body: <p>I am working with primefaces and I have the following problem, I have a toolbar with several buttons and components like inputtext and others in the form, but when I press the key <kbd>Enter</kbd> in some component the first button of the toolbar is called, in this case commandbutton "idButtomNuevo" is called because it is in the first position.</p>
  
  <p>My code: </p>
  
  <p>almacen.xhtml</p>
  
  <pre><code>&lt;ui:composition  
   xmlns="http://www.w3.org/1999/xhtml"
   xmlns:h="http://java.sun.com/jsf/html"
   xmlns:f="http://java.sun.com/jsf/core"
   xmlns:ui="http://java.sun.com/jsf/facelets"
   xmlns:p="http://primefaces.org/ui" &gt;
  
   &lt;h:form id="idFormAlmacen" &gt;
      &lt;p:focus context="idFormAlmacen"/&gt;
      &lt;p:growl id="growl" showDetail="true" life="2500" for="keyAlmacen" globalOnly="true"/&gt;
      &lt;p:panel header="Almacen" styleClass="texto-panel"/&gt;
      &lt;ui:include src="/pages/logistica/almacen/toolbar_almacen.xhtml"/&gt;
      &lt;ui:include src="#{almacenBean.pathbodyAlmacen}" /&gt;    
   &lt;/h:form&gt;
   &lt;ui:include src="/pages/logistica/almacen/dialogos_almacen.xhtml" /&gt;
  &lt;/ui:composition&gt; 
  </code></pre>
  
  <p>toolbar_almacen.xhtml</p>
  
  <pre><code>&lt;ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui"&gt;
      &lt;p:toolbar&gt;  
          &lt;p:toolbarGroup align="left" styleClass="panelgrid-css"&gt;
              &lt;p:commandButton id="idButtomNuevo" title="Nuevo"  icon="ui-icon-document" process="@this" value="Nuevo"
                      actionListener="#{almacenBean.limpiarAlmacen}" update="idFormAlmacen" immediate="true"&gt;
                   &lt;p:resetInput target="idFormAlmacen"/&gt;
              &lt;/p:commandButton&gt;
              &lt;p:commandButton id="idButtomGuardar" title="Guardar" icon="ui-icon-disk" action="#{almacenBean.guardarAlmacen}" 
                   disabled="#{almacenBean.au.btGuardarDisabled}" update=":idFormAlmacen" validateClient="true" value="Guardar"/&gt;
              &lt;p:commandButton id="idButtomEliminar" title="Eliminar" icon="ui-icon-trash" actionListener="#{almacenBean.eliminarAlmacen}"
                   disabled="#{almacenBean.au.btGuardarDisabled}" update="idFormAlmacen" process="@this" immediate="true"
                   value="Eliminar"/&gt;
              &lt;p:commandButton id="idButtomListar" title="Listar" icon="ui-icon-grip-solid-horizontal" process="@this" value="Listar"
                               actionListener="#{almacenBean.listarAlmacen}" update="idFormAlmacen" immediate="true"/&gt;
              &lt;p:commandButton id="idButtomBuscar" title="Buscar" icon="ui-icon-search" value="Buscar"
                               actionListener="#{almacenBean.buscarAlmacen}" immediate="true"&gt;
                  &lt;p:ajax event="dialogReturn" update="idFormAlmacen"/&gt;
              &lt;/p:commandButton&gt;
          &lt;/p:toolbarGroup&gt;  
      &lt;/p:toolbar&gt;
   &lt;/ui:composition&gt;
  </code></pre>
  
  <p>pathbodyAlmacen = "/pages/logistica/almacen/crear_almacen.xhtml"</p>
  
  <pre><code>&lt;ui:composition  
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui" &gt;
  
    &lt;p:panel header="Datos Generales de Almacen" /&gt;  
    &lt;h:panelGrid id="idPanelAlmacen1" columns="3" width="100%" border="0" columnClasses="colC1-T,colC2-T"&gt;
      &lt;p:outputLabel  for="idEmpresa" value="Empresa:" style="margin-right:2px;"/&gt;  
      &lt;p:inputText id="idEmpresa"  style="width:350px;" value="#{almacenBean.alVista.strEmpresa}" readonly="true"/&gt;  
      &lt;h:outputText value="&amp;#160;&amp;#160;&amp;#160;"/&gt;
  
      &lt;p:outputLabel for="idCodProveedor" value="Codigo:" style="margin-right:2px;"/&gt;  
      &lt;p:inputText id="idCodProveedor" value="#{almacenBean.alVista.codigo}" style="width:350px;" required="true"
                   requiredMessage="Ingrese Codigo "&gt;
          &lt;p:clientValidator /&gt;
      &lt;/p:inputText&gt;  
      &lt;p:message for="idCodProveedor" display="text"/&gt;
  
      &lt;p:outputLabel for="idNombre" value="Nombre:" style="margin-right:2px;"/&gt;  
      &lt;p:inputText id="idNombre" value="#{almacenBean.alVista.nombre}" style="width:350px;"
                   required="true" requiredMessage="Ingrese Nombre de Almacen"&gt;
          &lt;p:clientValidator event="keyup" /&gt;
      &lt;/p:inputText&gt;
      &lt;p:message for="idNombre" display="text"/&gt;
    &lt;/h:panelGrid&gt;
  
    &lt;h:panelGrid id="idPgDirAlmacen" columns="4" width="100%" border="0" columnClasses="colC1-T,colC2-T,colC3"&gt;
      &lt;p:outputLabel for="idInDirAlmacen" value="Direccion de Almacen:" style="margin-right:2px;" /&gt;
      &lt;p:inputText id="idInDirAlmacen" style="width:350px;" readonly="true" required="true"  value="#{almacenBean.alVista.direccionAlmacen}"
                   requiredMessage="Ingrese direccion de Almacen"/&gt;   
      &lt;p:commandButton title="Crear Direccion Almacen" actionListener="#{almacenBean.abrirDireccionAlmacen}"  process="@this"
                       icon="ui-icon-search" &gt;
          &lt;p:ajax event="dialogReturn" update=":idFormAlmacen:idPgDirAlmacen"/&gt;
      &lt;/p:commandButton&gt;
      &lt;p:message for="idInDirAlmacen" display="text"/&gt;
    &lt;/h:panelGrid&gt;
  &lt;/ui:composition&gt; 
  </code></pre>
  
  <p>thanks for all</p>