Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
java_dzienna_15_09
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
java_dzienna_15_09
Commits
0d9be63c
Commit
0d9be63c
authored
Oct 05, 2022
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Formularz edycji danych - na razie bez zapisu.
parent
66557678
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
0 deletions
+68
-0
ProductController.java
...ing/src/main/java/sklep/controller/ProductController.java
+17
-0
product.jsp
...SklepSpring/src/main/webapp/WEB-INF/templates/product.jsp
+1
-0
product_form.jsp
...Spring/src/main/webapp/WEB-INF/templates/product_form.jsp
+48
-0
products.jsp
...klepSpring/src/main/webapp/WEB-INF/templates/products.jsp
+2
-0
No files found.
PC30-SklepSpring/src/main/java/sklep/controller/ProductController.java
View file @
0d9be63c
...
@@ -38,4 +38,21 @@ public class ProductController {
...
@@ -38,4 +38,21 @@ public class ProductController {
}
}
}
}
@GetMapping
(
"/products/new"
)
public
String
newProduct
()
{
return
"product_form"
;
}
@GetMapping
(
"/products/{id}/edit"
)
public
String
editProduct
(
Model
model
,
@PathVariable
(
"id"
)
int
productId
)
{
Optional
<
Product
>
product
=
productRepository
.
findById
(
productId
);
if
(
product
.
isPresent
())
{
model
.
addAttribute
(
"product"
,
product
.
get
());
return
"product_form"
;
}
else
{
model
.
addAttribute
(
"product_id"
,
productId
);
return
"missing_product"
;
}
}
}
}
PC30-SklepSpring/src/main/webapp/WEB-INF/templates/product.jsp
View file @
0d9be63c
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
<p>
Cena:
<span
class=
"product-price"
>
${product.price}
</span></p>
<p>
Cena:
<span
class=
"product-price"
>
${product.price}
</span></p>
<p>
Stawka VAT:
<span
class=
"product-price"
>
${product.vat * 100}%
</span></p>
<p>
Stawka VAT:
<span
class=
"product-price"
>
${product.vat * 100}%
</span></p>
<p
class=
"product-description"
>
${product.description}
</p>
<p
class=
"product-description"
>
${product.description}
</p>
<div
class=
"action"
><a
href=
"/products/${product.productId}/edit"
>
Edytuj
</a></div>
</div>
</div>
<p><a
href=
"/products"
>
Przejdź do listy produktów
</a></p>
<p><a
href=
"/products"
>
Przejdź do listy produktów
</a></p>
...
...
PC30-SklepSpring/src/main/webapp/WEB-INF/templates/product_form.jsp
0 → 100644
View file @
0d9be63c
<
%@
page
language=
"java"
contentType=
"text/html; charset=UTF-8"
pageEncoding=
"UTF-8"
%
>
<
%@
taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%
>
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"UTF-8"
>
<title>
Edycja danych produktu
</title>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"/styl.css"
>
</head>
<body>
<h1>
Edycja produktu
</h1>
<form
id=
"product-form"
method=
"post"
>
<table
class=
"form"
>
<tr>
<td><label
for=
"productId"
>
Numer:
</label></td>
<td><input
name=
"productId"
placeholder=
"brak"
type=
"number"
readonly=
"readonly"
value=
"${product.productId}"
/></td>
</tr>
<tr>
<td><label
for=
"productName"
>
Nazwa towaru:
</label></td>
<td><input
name=
"productName"
placeholder=
"nazwa..."
type=
"text"
value=
"${product.productName}"
/>
</td>
</tr>
<tr>
<td><label
for=
"price"
>
Cena:
</label></td>
<td><input
name=
"price"
placeholder=
"12.90"
title=
"tu wpisz cenę"
type=
"number"
step=
"0.01"
value=
"${product.price}"
/>
</td>
</tr>
<tr>
<td><label
for=
"vat"
>
Stawka VAT:
</label></td>
<td><input
name=
"vat"
placeholder=
"0.23"
title=
"tu wpisz vat"
type=
"number"
step=
"0.01"
value=
"${product.vat}"
/>
</td>
</tr>
<tr>
<td><label
for=
"description"
>
Opis:
</label></td>
<td><textarea
name=
"description"
rows=
"10"
cols=
"120"
>
${product.description}
</textarea></td>
</tr>
<tr>
<td><button>
Zapisz
</button></td>
</tr>
</table>
</form>
<p>
[
<a
href=
"/products"
>
powrót do listy produktów
</a>
]
</p>
<p>
[
<a
href=
"/"
>
powrót do spisu treści
</a>
]
</p>
</body>
</html>
PC30-SklepSpring/src/main/webapp/WEB-INF/templates/products.jsp
View file @
0d9be63c
...
@@ -15,9 +15,11 @@
...
@@ -15,9 +15,11 @@
<p>
Towar
<a
href=
"products/${product.productId}"
class=
"product-name"
>
${product.productName}
</a></p>
<p>
Towar
<a
href=
"products/${product.productId}"
class=
"product-name"
>
${product.productName}
</a></p>
<p>
Cena:
<span
class=
"product-price"
>
${product.price}
</span></p>
<p>
Cena:
<span
class=
"product-price"
>
${product.price}
</span></p>
<p
class=
"product-description"
>
${product.description}
</p>
<p
class=
"product-description"
>
${product.description}
</p>
<div
class=
"action"
><a
href=
"/products/${product.productId}/edit"
>
Edytuj
</a></div>
</div>
</div>
</c:forEach>
</c:forEach>
<div><a
href=
"/products/new"
>
Dodaj nowy produkt
</a></div>
<div><a
href=
"/"
>
Wróć na stronę główną
</a></div>
<div><a
href=
"/"
>
Wróć na stronę główną
</a></div>
</body>
</body>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment