4 Replies Latest reply on Sep 8, 2009 7:07 PM by venuvanama

    rich modal window issue

      Hi,

      We are using rich faces 3.3.0, we are using rich modal window component for popups to perform lookups, on rich modal windows if the user hits on return after entering search criteria, modal window is closed and the parent form is submitted. Is there anyway to fix this problem, when the user hits return can we simulate click on search button to perform the search and not submit the parent form.

      Here is a sample of my code:

      <f:subview id="domainSearchModalPanelSubview" 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:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich">
      <a4j:region selfRendered="true">
      <rich:modalPanel id="domainSearchModalPanel" height="175" width="400">
      <f:facet name="header">
      <h:outputText value="Domain Search"/>
      </f:facet>
      <f:facet name="controls">
      <h:graphicImage value="/images/close.png" style="cursor:pointer" onclick="Richfaces.hideModalPanel('domainSearchModalPanel')" />
      </f:facet>
      <a4j:form id="domainSearchForm">
      <rich:spacer height="35px" />
      <a4j:status >
      <f:facet name="start">
      <h:graphicImage value="/images/loading.gif" />
      </f:facet>
      </a4j:status>
      <h:panelGrid id="domainNamePatternPanelGrid" columns="3" styleClass="detail" columnClasses="label">
      <h:outputLabel for="domainNamePattern">
      <h:outputText value="Name Pattern" />
      </h:outputLabel>
      <h:inputText id="domainNamePattern"
      binding="#{domainSearchBean.domainNamePatternInputText}"
      value="#{domainSearchBean.domainNamePattern}" />
      <a4j:commandButton
      id="searchButton" value="Search" action="#{domainSearchBean.onDomainSearch}"
      reRender="domainSearchResultPanelGrid" />
      </h:panelGrid>
      <h:panelGrid id="domainSearchResultPanelGrid" columns="2" styleClass="detail" columnClasses="label">
      <h:outputLabel for="domainName">
      <h:outputText value="Domain" />
      </h:outputLabel>
      <h:selectOneMenu id="domainName" binding="#{domainSearchBean.domainNameSelectOneMenu}" value="#{domainSearchBean.domainName}">
      <f:selectItem id="defaultDomainNameSelectItem" itemLabel="" />
      <f:selectItems id="domainNameSelectItems" value="#{domainSearchBean.domainNameSuggestions}" />
      </h:selectOneMenu>
      </h:panelGrid>
      <a4j:commandButton id="domainSearchOkButton" value="OK" action="#{domainSearchBean.onDomainSearchOk}" reRender="domainNamePanelGrid,domainNamePanelGrid2,domainNamePanelGrid3,domainNamePanelGrid4">
      <rich:componentControl for="domainSearchModalPanel" event="onclick" disableDefault="true" operation="hide">
      <f:param name="hide" value="componentControl work(hide)"/>
      </rich:componentControl>
      </a4j:commandButton>
      <a4j:commandButton id="domainSearchCancelButton" value="Cancel" action="#{domainSearchBean.onDomainSearchCancel}" reRender="domainNamePanelGrid,domainNamePanelGrid2,domainNamePanelGrid3,domainNamePanelGrid4">
      <rich:componentControl for="domainSearchModalPanel" event="onclick" disableDefault="true" operation="hide">
      <f:param name="hide" value="componentControl work(hide)"/>
      </rich:componentControl>
      </a4j:commandButton>
      </a4j:form>
      </rich:modalPanel>
      </a4j:region>
      </f:subview>

      Thanks for your help.

      Venu

        • 1. Re: rich modal window issue
          ilya_shaikovsky

          just handle the enter key with rich:hotKey.

          • 2. Re: rich modal window issue

            Thanks ilya_shaikovsky,

            With rich:hotKey can I simulate the onClick event on the search button instead of submitting the parent form. Do you do this with javascript or some other way. I would appreciate if you can provide me a sample code I can refer to.

            Venu

            • 3. Re: rich modal window issue
              ilya_shaikovsky

              just add hotKey as it show at demosite but using "return" in key attribute. And click to the needed button in handler attribute.

              • 4. Re: rich modal window issue

                Thanks ilya_shaikovsky,

                I tried using your suggestion, here is what I added to my modal window.

                <rich:hotKey key="return" handler="#{rich:clientId('searchBtn')}.click();return false;"/>

                I placed this inside the <h:form> tag. However it is still not working. When I press return, modal window is submits and closes the modal window.

                Can you please let me know where I am going wrong.

                Thanks,

                Venu