Lucrare de Laborator Nr.3: Obiect: Java Pe Calculator
Lucrare de Laborator Nr.3: Obiect: Java Pe Calculator
Chiinu 2014
Cod sursa:
//Adaugare
1
<%@page import="org.party.com.PlayerBean"%>
<%@page import="org.party.com.PlayerFactory"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<%
try{
String name = request.getParameter("player-name");
String tip= request.getParameter("player-tip");
int price = Integer.parseInt(request.getParameter("player-price"));
String photo = request.getParameter("player-photo");
if(name.length()==0) throw new Exception();
if(tip.length()==0) throw new Exception();
if(photo.length()==0) throw new Exception();
2
int id = Integer.parseInt(request.getParameter("player-id"));
String name = request.getParameter("player-name");
String tip = request.getParameter("player-tip");
int price = Integer.parseInt(request.getParameter("player-price"));
String photo = request.getParameter("player-photo");
%>
<%=id%>
<%response.setStatus(response.SC_MOVED_TEMPORARILY);
if(PlayerFactory.Edit(id, price, name, tip, photo))
response.setHeader("Location", "../index.jsp");
else
response.setHeader("Location", "../index.jsp");
}catch(Exception ex){%>
<%=ex%>
<%}
%>
</body> </html>
//Stergere
<%@page import="org.party.com.PlayerFactory"%>
4
<%=ex%>
<%}
%>
</body>
</html>
//Adaugare .jsp
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../style.css" type="text/css" />
<title>JSP Page</title>
</head>
<body>
<div id="mainContainer">
<div id="login" class="loginForm">
<div class="login-top">
</div>
6
<%
"Edit";formAction="actions/edit.jsp";enableInputs="";
%>
<div id="mainContainer">
<div id="login" class="loginForm">
<div class="login-top">
</div>
}else{
}catch(Exception ex){
%> error
<%}%>
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Laborator 3</title>
</head>
<body>
<div id="page-wrap">
<h1><a href="jsp/add.jsp" class="button-secondary purebutton">Adauga</a></h1>
<table >
<tr>
<td> Id </td>
<td>Name petrecere</td>
<td>Tip Torta</td>
<td>Price</td>
<td>Photo</td>
11
<td>Editeaza</td>
<td>Sterge</td>
</tr>
<tr>
<%
ArrayList<PlayerBean> players = PlayerFactory.players;
if(players.size() > 0)
{
for(PlayerBean player : players){
%>
<td><%= player.getId() %></td>
<td><%=player.getName()%></td>
<td><%=player.getTip()%></td>
<td><%=player.getPrice()%>$</td>
<td><img src="img/<%=player.getPhoto()%>"></td>
<td> <a href="jsp/delete_edit.jsp?action=edit&id=<%= player.getId()
%>"><img src="img/bif.png"></a> </td>
<td>
%>"><img src="img/delete.png"></a></td>
</tr>
12
<%
}
}else
{
%>
<h1 style="color: red"> nu sunt date!!!</h1>
<%
}%>
</div>
</table>
</body>
</html>
//Css
*{
margin: 0;
padding: 0;
}
body {
13
/*
Generic Styling, for Desktops/Laptops
*/
table {
width: 100%;
border-collapse: collapse;
}
/* Zebra striping */
tr:nth-of-type(1) {
background: #eee;
14
}
th {
background: #333;
color: white;
font-weight: bold;
}
td, th {
padding: 6px;
border: 1px solid #ccc;
text-align: center;
}
td img{
width:140px;
}
a img{
width: 40px;
}
15
.button-secondary {
color: #2E658C;
border-radius: 4px;
text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2);
}
.button-secondary:hover{
color: #1D4059;
a.button-secondary {
text-decoration: none;
}
/*
16
Form la adugare
*/
#mainContainer {
line-height: 20px;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
background-color: rgba(0,50,94,0.2);
margin: 20px auto;
display: table;
-moz-border-radius: 15px;
border-style: solid;
border-color: rgb(40, 40, 40);
border-radius: 2px 5px 2px 5px / 5px 2px 5px 2px;
border-radius: 2px;
border-radius: 2px 5px / 5px;
box-shadow: 0 5px 10px 5px rgba(0,0,0,0.2);
}
.loginForm {
17
width: 320px;
height: 400px;
padding: 10px 15px 25px 15px;
overflow: hidden;
}
.spacer {
18
padding-bottom: 10px;
}
label:hover ~ input[type=password] {
background:rgb(242, 242, 242);
}input[type=submit]:hover {
box-shadow:
inset 0 1px 0 rgba(255,255,255,0.3),
inset 0 -10px 10px rgba(255,255,255,0.1);
}
.login-top {
height: 85px;
}
.login-bottom {
padding: 35px 15px 0 0;
}
20