2 Replies Latest reply on Apr 16, 2013 10:57 AM by Flavio Palumbo

    How to block a popupPanel disappear when press enter key

    Flavio Palumbo Newbie

      Hi all,

      I have a simple form with a popupPanel, 2 input fields and a a4j:commandButton.

      I'd like that the user could exit from the panel either by submitting the form with the command button or by closing it.

      I discovered there is a third not wanted way : if the user press enter while the focus is on an input field the form disappears apparently without submitting the form.

      Can somebody help me to prevent this behavior ?

      I'm using rf 4.3.0.

      here is the code

       

      [code]

      <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:a4j="http://richfaces.org/a4j"

                      xmlns:ui="http://java.sun.com/jsf/facelets"

                      xmlns:es="http://java.sun.com/jsf/composite/esutils"

                      xmlns:rich="http://richfaces.org/rich">

          <rich:jQuery query="focus().select()" selector="#ESSocEditPanelGrid :input:visible:enabled:first" name="focusFirst"/>

      <!--   <f:event type="preRenderView" listener="#{eSSoc.preRenderView()}" /> -->

          <h:form id="ESSocEditPanelForm">

              <rich:popupPanel id="ESSocEditPanel" autosized="false" keepVisualState="false" domElementAttachment="parent"

                               width="720" height="325" headerClass="panel-header-class" resizeable="true" onshow="focusFirst();">

                  <f:facet name="header">

                      <h:outputText value="#{eSSoc.headerEditPanel}"/>

                  </f:facet>

                  <f:facet name="controls">

                      <es:esUtilClosePanel varAction="#{rich:component('ESSocEditPanel')}.hide();"/>

                  </f:facet>

                  <a4j:outputPanel id="ESSocTableMod" ajaxRendered="true">

                      <rich:panel>

                          <h:panelGrid columns="2" id="ESSocEditPanelGrid">

                              <h:outputText value="#{mess.labelSocId}" styleClass="std-label"/>

                              <h:outputText value="#{eSSoc.ESSoc.a2id}" rendered="#{!eSSoc.insert}"/>

                              <h:inputText id="A2_0" value="#{eSSoc.key}" size="7" maxlength="7"

                                           rendered="#{eSSoc.insert}" style="#{eSSoc.getStyle('0')}" />

                              <h:outputText value="#{mess.labelSocDes}" styleClass="std-label"/>

                              <h:inputText id="A2_1" value="#{eSSoc.ESSoc.a2deso}" size="60"

                                           maxlength="100" style="#{eSSoc.getStyle('1')}"/>

                          </h:panelGrid>

                      </rich:panel>

                      <rich:panel>

                          <h:panelGrid columns="2">

                              <h:outputText value="#{mess.labelUserIns}" styleClass="std-label"/>

                              <h:outputText value="#{eSSoc.ESSoc.a2usin}" />

                              <h:outputText value="#{mess.labelDataIns}" styleClass="std-label"/>

                              <h:outputText value="#{eSSoc.ESSoc.a2dtin}" >

                                  <f:convertDateTime pattern="#{curLocale.dateTimePattern}" timeZone="#{esUty.curTZ}" />

                              </h:outputText>

                              <h:outputText value="#{mess.labelUserVar}" styleClass="std-label"/>

                              <h:outputText value="#{eSSoc.ESSoc.a2usva}" />

                              <h:outputText value="#{mess.labelDataVar}" styleClass="std-label"/>

                              <h:outputText value="#{eSSoc.ESSoc.a2dtva}"  >

                                  <f:convertDateTime pattern="#{curLocale.dateTimePattern}" timeZone="#{esUty.curTZ}" />

                              </h:outputText>

                          </h:panelGrid>

                      </rich:panel>

                      <rich:panel>

                          <a4j:commandButton action="#{eSSoc.confirmData}" render="ESSocTable"

                                             oncomplete="if (!ajaxRequestContainsErrors()) #{rich:component('ESSocEditPanel')}.hide();"

                                             image="/resources/images/check.png" title="#{mess.tipConferma}"/>

                      </rich:panel>

                  </a4j:outputPanel>

              </rich:popupPanel>

          </h:form>

      </ui:composition>

      [/code]