You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Nisith Dash <ni...@tcscal.co.in> on 2003/09/26 17:53:00 UTC

how to submit a action form using a javascript(pop-up).

Hi all,

I have a problem and need you help for resolution.I have a JSP struts page with an action form with typically save,delete buttons.One of the fields in this form is a search criteria field with a Go button which should basically display the results in a new pop up window.I have associated a new action class for this button.I want to submit the entire action form associated with this page  to be submitted when i click the Go button through a javascript function.  

Also when i select a value in the popup window and return back to the main form, the values already existing  in the action form should not get repopulated(ie avoiding the call to the reset method of the action class).


I am providing the code snippet for the same, in which i have been able to pass the search parameter rather than submitting entire action form:

function openSearchProductPopup()
  {
         var URL= '/rpm/findCompanyCdAction.do?searchcode='+BusinessDivisionForm.ecmPkey.value;
         features="alwaysRaised=yes,dependent=yes,menubar=no,toolbar=no,scrollbars=yes,height=400,width=600";
         window.open(URL,"",features);
  }


<html:form  action="createBusinessDivisionAction">
          <table id=Table5 cellSpacing=1 cellPadding=1 width="100%" border=0>
            <label  class=prompt> Company Id:</label></div>
              </td>
              <td height=26 > 
                <html:text property="ecmPkey" maxlength="38" styleClass="inputCellNumShaded"/>
                <html:button  styleClass="button" property="go"  value="Go"  onclick='openSearchProductPopup();' />
              </td>
              <td align=left height=26> 
                <div align=right class="prompt"><span class=requiredFieldAsterisk>*</span>&nbsp;<label class=requiredFieldPrompt> Division Id:</label></div>
              </td>
              <td height=26 > 
                <html:text property="divisionCd" maxlength="15" styleClass="inputCellShaded"/>
              </td>
              <td width="43" height=26></td>
            </tr>
            <tr> 
              <td width="46" height="33"></td>
              <td align=left height=33> 
                <div align=right class="prompt"><span class=requiredFieldAsterisk>*</span>&nbsp;<label class=requiredFieldPrompt> Divsion Name:</label></div>
              </td>
              <td class="prompt" height="33"> 
               <html:text property="divisionName" maxlength="100" styleClass="inputCellShaded"/>
              </td>
              <td class=prompt align=right height="33">&nbsp;</td>
              <td colSpan=2 height="33" width="185">&nbsp; </td>
            </tr>
            <tr> 
              <td width="40"></td>
              <td class="prompt" align=right><label class=prompt>Created By:</label></td>
              <td width="186"> 
                <html:text property="userCreated" maxlength="10" styleClass="formObjReadOnly" readonly="true"/>
              </td>
              <td class=prompt align=right> 
                <div align=right><label class=prompt>Created On:</label></div>
              </td>
              <td width="250" > 
                <html:text property="dateCreated" maxlength="7" styleClass="formObjReadOnly" readonly="true"/>
              </td>
              <td width="10"></td>
            </tr>
            <tr> 
              <td width="40"></td>
              <td class=prompt align=right> 
                <div align=right><label
                class=prompt>Last Updated By:</label></div>
              </td>
              <td width="186" > 
                <html:text property="userLastUpd" maxlength="10" styleClass="formObjReadOnly" readonly="true"/>
              </td>
              <td class=prompt align=right> 
                <div align=right><label class=prompt>Last Updated On:</label></div>
              </td>
              <td width="250" > 
                <html:text property="dateLastUpd" maxlength="7" styleClass="formObjReadOnly" readonly="true"/>
              </td>
              <td width="10"></td>
            </tr>     
             <html:hidden property="ebdPkey" />
            <tr> 
              <td width="600" colspan="5"> 
                <div align="left"> 
                <html:button onclick='createForm();'  styleClass="button" property="Save" value="Save" />&nbsp;&nbsp;<html:button onclick='deleteForm(); '        styleClass="button" property="Delete" value="Delete" />&nbsp;&nbsp;<html:button  styleClass="button" property="Reset" value="Reset" />&nbsp;&nbsp;<html:button  styleClass="button" property="Close" value="Close" />&nbsp; </div>
              </td>
              <td width="43"></td>
            </tr>            
          </table>        
        </html:form>


and the struts config is as follows:

<action path="/findCompanyCdAction" 
            type="com.rpm.application.common.action.FindCompanyCdAction"
            input="/jsp/common/RPMCOM002MaintainDivision.jsp"> 
            name="BusinessDivisionForm"       
            scope="request">    
             <exception type="com.rpm.framework.exception.RPMCustomWrappedNonRecoverableException" 
              handler="com.rpm.framework.exception.handler.RPMExceptionHandler" 
              path="/jsp/common/RPMCOM002MaintainDivision.jsp" key="" scope="request"/>
           <forward name="success" path="/jsp/common/RPMCOM022ListCompanyDetails.jsp"  />
           <forward name="default" path="/jsp/common/RPMCOM002MaintainDivision.jsp"  />
</action>   

Thanks in advance,

Nisith

Re: how to submit a action form using a javascript(pop-up).

Posted by Jan Van Stalle <ja...@skynet.be>.
to submit your form using javascript, do something like document.forms[0].submit();

Jan
  "Nisith Dash" <ni...@tcscal.co.in> wrote in message news:004a01c38446$4304c8b0$5a1412ac@tcskolkata.co.in...
  Hi all,

  I have a problem and need you help for resolution.I have a JSP struts page with an action form with typically save,delete buttons.One of the fields in this form is a search criteria field with a Go button which should basically display the results in a new pop up window.I have associated a new action class for this button.I want to submit the entire action form associated with this page  to be submitted when i click the Go button through a javascript function.  

  Also when i select a value in the popup window and return back to the main form, the values already existing  in the action form should not get repopulated(ie avoiding the call to the reset method of the action class).


  I am providing the code snippet for the same, in which i have been able to pass the search parameter rather than submitting entire action form:

  function openSearchProductPopup()
    {
           var URL= '/rpm/findCompanyCdAction.do?searchcode='+BusinessDivisionForm.ecmPkey.value;
           features="alwaysRaised=yes,dependent=yes,menubar=no,toolbar=no,scrollbars=yes,height=400,width=600";
           window.open(URL,"",features);
    }


  <html:form  action="createBusinessDivisionAction">
            <table id=Table5 cellSpacing=1 cellPadding=1 width="100%" border=0>
              <label  class=prompt> Company Id:</label></div>
                </td>
                <td height=26 > 
                  <html:text property="ecmPkey" maxlength="38" styleClass="inputCellNumShaded"/>
                  <html:button  styleClass="button" property="go"  value="Go"  onclick='openSearchProductPopup();' />
                </td>
                <td align=left height=26> 
                  <div align=right class="prompt"><span class=requiredFieldAsterisk>*</span>&nbsp;<label class=requiredFieldPrompt> Division Id:</label></div>
                </td>
                <td height=26 > 
                  <html:text property="divisionCd" maxlength="15" styleClass="inputCellShaded"/>
                </td>
                <td width="43" height=26></td>
              </tr>
              <tr> 
                <td width="46" height="33"></td>
                <td align=left height=33> 
                  <div align=right class="prompt"><span class=requiredFieldAsterisk>*</span>&nbsp;<label class=requiredFieldPrompt> Divsion Name:</label></div>
                </td>
                <td class="prompt" height="33"> 
                 <html:text property="divisionName" maxlength="100" styleClass="inputCellShaded"/>
                </td>
                <td class=prompt align=right height="33">&nbsp;</td>
                <td colSpan=2 height="33" width="185">&nbsp; </td>
              </tr>
              <tr> 
                <td width="40"></td>
                <td class="prompt" align=right><label class=prompt>Created By:</label></td>
                <td width="186"> 
                  <html:text property="userCreated" maxlength="10" styleClass="formObjReadOnly" readonly="true"/>
                </td>
                <td class=prompt align=right> 
                  <div align=right><label class=prompt>Created On:</label></div>
                </td>
                <td width="250" > 
                  <html:text property="dateCreated" maxlength="7" styleClass="formObjReadOnly" readonly="true"/>
                </td>
                <td width="10"></td>
              </tr>
              <tr> 
                <td width="40"></td>
                <td class=prompt align=right> 
                  <div align=right><label
                  class=prompt>Last Updated By:</label></div>
                </td>
                <td width="186" > 
                  <html:text property="userLastUpd" maxlength="10" styleClass="formObjReadOnly" readonly="true"/>
                </td>
                <td class=prompt align=right> 
                  <div align=right><label class=prompt>Last Updated On:</label></div>
                </td>
                <td width="250" > 
                  <html:text property="dateLastUpd" maxlength="7" styleClass="formObjReadOnly" readonly="true"/>
                </td>
                <td width="10"></td>
              </tr>     
               <html:hidden property="ebdPkey" />
              <tr> 
                <td width="600" colspan="5"> 
                  <div align="left"> 
                  <html:button onclick='createForm();'  styleClass="button" property="Save" value="Save" />&nbsp;&nbsp;<html:button onclick='deleteForm(); '        styleClass="button" property="Delete" value="Delete" />&nbsp;&nbsp;<html:button  styleClass="button" property="Reset" value="Reset" />&nbsp;&nbsp;<html:button  styleClass="button" property="Close" value="Close" />&nbsp; </div>
                </td>
                <td width="43"></td>
              </tr>            
            </table>        
          </html:form>


  and the struts config is as follows:

  <action path="/findCompanyCdAction" 
              type="com.rpm.application.common.action.FindCompanyCdAction"
              input="/jsp/common/RPMCOM002MaintainDivision.jsp"> 
              name="BusinessDivisionForm"       
              scope="request">    
               <exception type="com.rpm.framework.exception.RPMCustomWrappedNonRecoverableException" 
                handler="com.rpm.framework.exception.handler.RPMExceptionHandler" 
                path="/jsp/common/RPMCOM002MaintainDivision.jsp" key="" scope="request"/>
             <forward name="success" path="/jsp/common/RPMCOM022ListCompanyDetails.jsp"  />
             <forward name="default" path="/jsp/common/RPMCOM002MaintainDivision.jsp"  />
  </action>   

  Thanks in advance,

  Nisith


------------------------------------------------------------------------------


  ---------------------------------------------------------------------
  To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
  For additional commands, e-mail: struts-user-help@jakarta.apache.org