6 Replies Latest reply on Jun 18, 2008 11:11 AM by asookazian

    using a4j:support onblur and onclick js confirm at same time

    asookazian

      using RF3.2.0.SR1

      In the below code fragment from a xhtml, the submit is not happening (blocked) due to the js confirmation popup. When I remove the onclick confirm for the submit, it saves the record(s) fine.

      How can I validate the contents of the barcode column/cell and display a confirmation popup when user clicks submit button?

      <rich:panel>
       <rich:dataTable id="dataTable1" value="#{addHardware.hardwareAndHardwareNoteList}" var="list">
       <rich:column width="2%">
       <f:facet name="header"><h:outputText value="#"/></f:facet>
       <h:outputText id="row" value="#{list.rowCount}"/>
       </rich:column>
       <rich:column width="5%">
       <f:facet name="header"><h:outputText value="Barcode"/></f:facet>
       <h:inputText id="barcode" maxlength="5" size="10" value="#{list.o1.coxBarcode}" valueChangeListener="#{addHardware.processValueChange}">
       <!-- Commercial/Residential value was not being set unless user selected it or onblur of serialNo below... so removing ajaxSingle="true" for barcode a4j:support -->
       <a4j:support event="onblur" reRender="displayMessageLabel, errmsgheader, submit"/>
       </h:inputText>
       </rich:column>
       <rich:column width="5%">
       <f:facet name="header"><h:outputText value="Serial Number"/></f:facet>
       <h:inputText id="serialNumber" value="#{list.o1.serialNo}" maxlength="20" size="25" onblur="autoTab(this)">
       <!-- is the a4j:support below necessary?? -->
       <!-- <a4j:support event="onblur"/> -->
       </h:inputText>
       </rich:column>
       <rich:column width="48%">
       <f:facet name="header"><h:outputText value="Notes"/></f:facet>
       <h:inputText id="notes" value="#{list.o2.hardwareNote}" size="120" maxlength="2000">
       <!-- <a4j:support event="onblur"/> -->
       </h:inputText>
       </rich:column>
       </rich:dataTable>
      
       <h:commandButton id="submit" value="Submit" onclick="return confirmMode('Submit');" action="#{addHardware.populateHardwareAndNotes}" disabled="#{addHardware.submitDisabled}"/>
       <h:commandButton id="cancel" value="Cancel" onclick="return confirmMode('Cancel')" action="#{addHardware.cancel}" disabled="false"/>
      
      
       </rich:panel>


        • 1. Re: using a4j:support onblur and onclick js confirm at same
          asookazian

          <p>when I do this: <br/> <br/>["><h:commandButton id="submit" value="Submit" onclick="return true;" action="#{addHardware.populateHardwareAndNotes}" disabled="#{addHardware.submitDisabled}"/> | <h:commandButton id=] <br/> <br/>it works so that means the popping up of the confirmation dialog onclick event is preventing the SFSB method from being executed. <br/> <br/>is there any way around that or do I need to simply remove the &quot;are you sure you want to submit?&quot; confirmation?</p>

          • 2. Re: using a4j:support onblur and onclick js confirm at same
            asookazian

            sorry, this is the new code I tried...

            <h:commandButton id="submit" value="Submit" onclick="return true;" action="#{addHardware.populateHardwareAndNotes}" disabled="#{addHardware.submitDisabled}"/>


            • 3. Re: using a4j:support onblur and onclick js confirm at same
              asookazian

              .js function:

              
              function confirmMode(modeString) {
               var returnVal = false;
               var confirmStr = "Do you wish to "+modeString;
               var answer;
              
               confirmStr = confirmStr + " ? ";
               answer=window.confirm(confirmStr);
               if (answer==true) {
               returnVal = true;
               }
               else {
               returnVal = false;
               }
              
               return returnVal;
               }


              • 4. Re: using a4j:support onblur and onclick js confirm at same
                ilya_shaikovsky

                do not return anything if you need request to be sent and return false in other case.

                • 5. Re: using a4j:support onblur and onclick js confirm at same
                  asookazian

                  I tried that as follows and it doesn't work, still does not submit request:

                  function confirmMode(modeString) {
                  
                   var confirmStr = "Do you wish to "+modeString;
                   var answer;
                  
                   confirmStr = confirmStr + " ? ";
                   answer=window.confirm(confirmStr);
                   if (answer==false) {
                   return false;
                   }
                  
                   }


                  • 6. Re: using a4j:support onblur and onclick js confirm at same
                    asookazian

                    the following code in xhtml with rich:modalPanel works fine:

                    <rich:panel>
                     <rich:dataTable id="dataTable1" value="#{hardwareAndHardwareNoteList}" var="list">
                     <rich:column width="2%">
                     <f:facet name="header"><h:outputText value="#"/></f:facet>
                     <h:outputText id="row" value="#{list.rowCount}"/>
                     </rich:column>
                     <rich:column width="5%">
                     <f:facet name="header"><h:outputText value="Barcode"/></f:facet>
                     <!-- <h:inputText id="barcode" maxlength="5" size="10" value="#{list.o1.coxBarcode}" valueChangeListener="#{addHardware.processValueChange}"> -->
                     <h:inputText id="barcode" maxlength="5" size="10" value="#{list.o1.coxBarcode}">
                     <s:validate/>
                     <a4j:support event="onblur" action="#{addHardware.processValueChange(hardwareAndHardwareNoteList.getRowIndex())}" reRender="barcode, submit"/>
                     </h:inputText>
                     </rich:column>
                     <rich:column width="5%">
                     <f:facet name="header"><h:outputText value="Serial Number"/></f:facet>
                     <h:inputText id="serialNumber" value="#{list.o1.serialNo}" maxlength="20" size="25" onblur="autoTab(this)"/>
                     </rich:column>
                     <rich:column width="48%">
                     <f:facet name="header"><h:outputText value="Notes"/></f:facet>
                     <h:inputText id="notes" value="#{list.o2.hardwareNote}" size="120" maxlength="2000"/>
                     </rich:column>
                     </rich:dataTable>
                    
                     <a4j:commandButton id="submit" type="button" value="Submit" onclick="Richfaces.showModalPanel('mpConfirmSubmit')" disabled="#{addHardware.submitDisabled}"/>
                     <a4j:commandButton id="cancel" type="button" value="Cancel" action="#{addHardware.cancel}" disabled="false"/>
                     </rich:panel>
                    
                    
                     <h:inputHidden id="tempcompid" value="#{addHardware.compId}"/><br></br>
                    
                     </body>
                     </h:form>
                    
                     <rich:modalPanel id="mpConfirmSubmit" minHeight="200" minWidth="450" height="200" width="450">
                    
                     <f:facet name="header">
                     <a4j:outputPanel>
                     <h:outputText id="mpConfirmation" value="Confirmation"/>
                     </a4j:outputPanel>
                     </f:facet>
                    
                     <a4j:form id="a4jChangePeer">
                     <h:outputText value="Are you sure you want to submit?"/>
                     <BR/>
                     <h:panelGrid columns="2">
                     <a4j:commandButton value="ok" ajaxSingle="true" action="#{addHardware.populateHardwareAndNotes}" onclick="Richfaces.hideModalPanel('mpConfirmSubmit');"/>
                    
                     <BR/>
                     <a4j:commandButton value="cancel" onclick="Richfaces.hideModalPanel('mpConfirmSubmit');return false;"/>
                    
                     </h:panelGrid>
                     </a4j:form>
                    
                     </rich:modalPanel>