Dear everybody,
I have a jsp page, with two forms, and I want to perform two different
actions when the button 'accept' is pressed.
I thought I had gotten this problem solved, but I noticed that only one
action is being performed in the function transferData().
When the button 'accept' is pressed, I send the control to this function
that will set the two action and submit them.
If I comment the lines related to form 1, the action for form 2 is executed
perfectly.
If I comment the lines related to form 2, the action for form 1 is executed
perfectly.
But... they do not work together.
The question is:
How can I make my jsp page execute the two actions (or more) at the same
time????
The code is bellow. Any help is welcome.
Thanks
sio
============================================================================
=======
<!-- daPubEditDocDlogContent.jsp -->
<!-- $$ BEGIN PAGE DIRECTIVE -->
<%@ page language = "java" %>
<%@ page import = "java.util.*" %>
<!-- $$ END PAGE DIRECTIVE -->
<%
String header = request.getHeader("Host");
int documentID = 0;
String documentIDStr = "";
int parentFolderID = 0;
String parentFolderIDStr = "";
String title = "";
String notes = "";
String action = "";
String pipFormRef = "";
String formTitle = "";
String user = "";
String relativePath = "Presentations";
HttpSession pipSession = request.getSession(false);
if (pipSession == null )
{
out.println("Session is NULL");
return;
}
//String UserID = (String)pipSession.getAttribute("UserID");
//out.println(UserID);
user = (String)pipSession.getAttribute("owner");
String appName = PIPServices.pipProperties.getProperty("appName");
documentIDStr = request.getParameter("documentID");
parentFolderIDStr = request.getParameter("parentFolderID");
if (documentIDStr != null)
{
documentID = Integer.parseInt(documentIDStr);
}
if (parentFolderIDStr != null)
{
parentFolderID = Integer.parseInt(parentFolderIDStr);
}
if (documentID == 0)
{
pipFormRef = "addADocument_PF";
action = "http://" + header + "/" + appName +
"/servlet/PIP";
formTitle = "Add a Document";
}
else
{
pipFormRef = "updateDoc_PF";
action = "http://" + header + "/" + appName +
"/servlet/PIP";
formTitle = "Edit a Document";
PIPSnapRecset myPIPSnapRecset = null;
PipServerUtil myPIPUtilObj = null;
myPIPSnapRecset=
(PIPSnapRecset)pipSession.getAttribute("myPipSnapRecset");
myPIPUtilObj =
(PipServerUtil)pipSession.getAttribute("myPIPUtilObj");
String snapURL = "http://" + header + "/" +
appName +
"/servlet/PIP?request=execSnap&snapRef=getDocInfo&documentID=" +
documentID;
String snapoutputXML = myPIPUtilObj.LoadServlet(snapURL);
Hashtable srchResults = new Hashtable();
srchResults =myPIPSnapRecset.getDataFRec(snapoutputXML, 0,
srchResults);
title = (String) srchResults.get("title");
notes = (String) srchResults.get("notes");
}
%>
<script language=javascript>
////////////////////////////////////////////////////////////////////////////
///
// submit to appropriate servlet/jsp
//
function transferData()
{
objfrm1 = document.PublishEditDocument1;
objfrm1.action =
"http://localhost:8100/pip6961/servlet/UploadServlet";
objfrm1.method = "post";
objfrm1.submit();
objfrm2 = document.PublishEditDocument2;
objfrm2.action = "<%=action%>";
objfrm2.method = "post";
objfrm2.submit();
}
</script>
<html>
<head>
<title> PIP Portal </title>
</head>
<body>
<p> <b><font color="#008080" size="4">Uci </font><font
size="4">Wizard</font></b>
<font size="4">- <b>Publish Document</b></font>
</p>
<FORM name=PublishEditDocument1 enctype="multipart/form-data">
<table border="0" width="100%" height="227">
<tr>
<td width="10%" height="25">Document:</td>
<td width="90%" height="25"><input type=file size=20
name="fname"></td>
<input type="hidden" name="user" value="<%=user%>">
<input type="hidden" name="relativePath"
value="<%=relativePath%>">
</tr>
</table>
<p>
</p>
</form>
<FORM name=PublishEditDocument2>
<table border="0" width="100%" height="227">
<tr>
<td width="10%" height="25">Title:</td>
<td width="90%" height="25"><input type="text" name="title"
size="80" value="<%=title%>"></td>
</tr>
<tr>
<td width="10%" height="109" valign="top">Notes:</td>
<td width="90%" height="109" valign="top"><textarea rows="3"
name="notes" cols="69"><%=notes%></textarea></td>
</tr>
<tr>
<input type="hidden" name="documentID"
value="<%=documentID%>">
<input type="hidden" name="parentFolderID"
value="<%=parentFolderID%>">
<input type="hidden" name="pipFormRef"
value="<%=pipFormRef%>">
<input type="hidden" name="request"
value="execPIPForm">
<td width="10%" height="21"> </td>
<td width="90%" height="21"> </td>
</tr>
<tr>
<td width="10%" height="27"> </td>
<td width="90%" height="27">
<input type="button" value="Accept" name="btnAccept"
onclick="javascript:return
transferData()">
<input type="reset" name="btnReset" value="Cancel">
</td>
</tr>
</table>
<p>
</p>
</form>
</body>
</html>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets