📄 updateproduct.jsp
字号:
<%--
* @author Anupama Majety
* @version 1.0
*
* Development Environment : Oracle9i JDeveloper
* Name of the Application : UpdateProduct.jsp
* Creation/Modification History :
*
* Anupama Majety 22-Jan-2002 Created
*
* Overview of Application :
* This JSP displays the form fields to be filled by the manufacturer
* for updating the selected product in database.
--%>
<%@ page language="java" %>
<%@ page errorPage="Exception.jsp" %>
<%@ page import="oracle.otnsamples.AQ.Helper.Product"%>
<HTML><HEAD><TITLE>Advanced Queuing Sample - Update A Product</TITLE>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<link rel="stylesheet" href="stylesheets/styles.css" type="text/css">
<script src="include/validation.js" language="JavaScript"></script>
<script language="JavaScript1.1">
// This function is called when the manufacturer wants to update a product to his
// database. It submits the form to the ControllerServlet appending the
// appropriate event after validating the form. If an error message is
// returned after validation then the message is alert and the form is not
// submitted.
function updateProduct(){
var errorMessage=validationForm();
if(errorMessage==""){
document.UpdatePrdFrm.action = "ControllerServlet?Event=UpdateProduct";
document.UpdatePrdFrm.submit();
}else{
alert(errorMessage);
}
}
// This function is called when the manufacturer wants to reset the form i.e.
// erase all the values he entered previously.
function resetForm(){
document.UpdatePrdFrm.ProductDesc.value="";
document.UpdatePrdFrm.CategoryDesc.value="";
document.UpdatePrdFrm.Price.value="";
document.UpdatePrdFrm.Quantity.value="";
}
// This function is used to validate all the fields entered by the user.
// These are the validations done - Product Description, quantity
// and price shouldn't be empty. Price and Quantity should be a positive
// integer and Quantity shouldn't contain a fractional part.
// Finally this method returns the errors present in all the form fields.
function validationForm(){
var errorMessage="";
// Check if product description is empty. If it is then display an alert.
if(isEmpty(document.UpdatePrdFrm.ProductDesc.value)){
errorMessage+="Product Desc should'nt be empty\n";
}
var price=document.UpdatePrdFrm.Price.value;
// Check if price is empty. If it is then display an alert.
if(isEmpty(price)){
errorMessage+="Product Price should'nt be empty\n";
}else{
// If price is not empty then check if it is a postive number or not.
if(!isNumber(price)){
errorMessage+="Price should be Positive number greater than zero\n";
}
}
var quantity=document.UpdatePrdFrm.Quantity.value;
// Check if quantity entered is empty. If it is then display an alert.
if(isEmpty(quantity)){
errorMessage+="Quantity should'nt be empty\n";
}else{
// If quantity entered is not empty then check to see if it is
// an positive number.
if(isNumber(quantity)){
if(isCharPresent(".",quantity)){
errorMessage+="Quantity should be an Integer\n ";
}
}else{
errorMessage+="Quantity should be Positive integer greater than zero\n";
}
}
return errorMessage;
}
</script>
<META content="MSHTML 5.00.2314.1000" name=GENERATOR></HEAD>
<BODY bgColor=#ffffff text=#000000>
<form name="UpdatePrdFrm" method="post" >
<!-- Main table -->
<jsp:include page="include/Top.jsp" />
<SPAN class="greeting"> Hi <%= (String)session.getAttribute("Name")%>. You have logged in as a Computer Manufacturer.</SPAN>
<jsp:include page="include/Links.jsp" />
<!-- Heading of the page goes here -->
<TR><TD class="mainHeading" align="center">Update a Product</TD></TR>
<TR><TD> </TD></TR>
<TR>
<TD>
<!-- 5th table starts here working area -->
<TABLE border=0 cellPadding=0 cellSpacing=0 width=970>
<TBODY>
<TR>
<TD valign="top" width="15%" noWrap> </TD>
<TD vAlign=top width="75%" align="center">
<!-- 6th table starts here-->
<%
Product product=(Product)request.getAttribute("UpdatePrdInfo");
%>
<TABLE border=0 width="60%">
<TBODY>
<TR>
<TD class="formHeading" align="right">Product Id</TD>
<TD> </TD>
<TD class="data"> <%= product.getProductID()%>
<input type="hidden" name="ProductId" value="<%= product.getProductID()%>">
</TD>
</TR>
<TR>
<TD class="formHeading" align="right">Product Name</TD>
<TD> </TD>
<TD class="data"> <%= product.getProductName()%>
<input type="hidden" name="ProductName" value="<%= product.getProductName()%>">
</TD>
</TR>
<TR>
<TD align="right"><span class="formHeading">Product Desc </span>
<span class="errorMessage">*</span></TD>
<TD> </TD>
<TD class="data">
<textarea name="ProductDesc" rows="4" cols="30" ><%= product.getProductDesc()%></textarea>
</TD>
</TR>
<TR>
<TD class="formHeading" align="right">Category Desc</TD>
<TD> </TD>
<TD class="data">
<%
String catDesc="";
if((product.getCategoryDesc()==null)|| product.getCategoryDesc().equals("")){
catDesc="";
}else{
catDesc=product.getCategoryDesc();
}
%>
<textarea name="CategoryDesc"><%= catDesc%>
</textarea>
</TD>
</TR>
<TR>
<TD align="right"><span class="formHeading">Price</span>
<span class="errorMessage">*</span></TD>
<TD> </TD>
<TD class="data">
<input type="text" name="Price" size="15" value="<%= product.getProductPrice()%>">
<span class="formHeading">$</span>
</TD>
</TR>
<TR>
<TD align="right"><span class="formHeading">Quantity</span>
<span class="errorMessage">*</span></TD>
<TD> </TD>
<TD class="data">
<input type="text" name="Quantity" size="6" maxlength="6" value="<%= product.getQuantityOnHand()%>">
</TD>
</TR>
</TBODY>
</TABLE>
<!-- 6th table ends here -->
</TD>
<TD width="10%"> </TD>
</TR>
<TR><TD colspan=3> </TD></TR>
<TR>
<TD colspan=3 align="center"><img src="images/Update.gif" border=0 width="60" height="32" onMouseUp="updateProduct()">
<img src="images/reset12.gif" border=0 width="60" height="32" onMouseUp="resetForm()">
</TD>
</TR>
</TBODY>
</TABLE>
<!-- 5th table ends here working area-->
</TD>
</TR>
<TR>
<TD vAlign=top align=left noWrap> </TD>
</TR>
<TR>
<TD vAlign=top align=left ><image src="images/line.gif" height="3" width="970"></TD>
</TR>
<TR>
<TD height=19 vAlign=top align="left"><font face="Arial, Helvetica" size=-2>
© Copyright 2002 Oracle Corporation.
All rights reserved.</font> </TD>
</TR>
</TABLE>
<!-- Main table ends here-->
</form>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -