Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
javab_20230617
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
javab_20230617
Commits
1c831148
Commit
1c831148
authored
Jul 29, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
f:form
parent
0b188b34
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
23 deletions
+34
-23
ProductController.java
...ing/src/main/java/sklep/controller/ProductController.java
+1
-1
product_form.jsp
...Spring/src/main/webapp/WEB-INF/templates/product_form.jsp
+33
-22
No files found.
PC27-SklepSpring/src/main/java/sklep/controller/ProductController.java
View file @
1c831148
...
@@ -73,7 +73,7 @@ public class ProductController {
...
@@ -73,7 +73,7 @@ public class ProductController {
// Metoda jest wywoływana zawsze, a to programista ma sprawdzić czy walidacja się powiodła.
// Metoda jest wywoływana zawsze, a to programista ma sprawdzić czy walidacja się powiodła.
// W BindingResult znajdują się też informacje o błędach.
// W BindingResult znajdują się też informacje o błędach.
if
(
bindingResult
.
hasErrors
())
{
if
(
bindingResult
.
hasErrors
())
{
System
.
err
.
println
(
"Błędy w formulazu: "
+
bindingResult
.
getAllErrors
());
System
.
err
.
println
(
"Błędy w formula
r
zu: "
+
bindingResult
.
getAllErrors
());
// nie próbujemy robić save
// nie próbujemy robić save
}
else
{
}
else
{
System
.
out
.
println
(
"id przed zapisem: "
+
product
.
getProductId
());
System
.
out
.
println
(
"id przed zapisem: "
+
product
.
getProductId
());
...
...
PC27-SklepSpring/src/main/webapp/WEB-INF/templates/product_form.jsp
View file @
1c831148
<
%@
page
language=
"java"
contentType=
"text/html; charset=UTF-8"
pageEncoding=
"UTF-8"
%
>
<
%@
page
language=
"java"
contentType=
"text/html; charset=UTF-8"
pageEncoding=
"UTF-8"
%
>
<
%@
taglib
prefix=
"c"
uri=
"jakarta.tags.core"
%
>
<
%@
taglib
prefix=
"c"
uri=
"jakarta.tags.core"
%
>
<
%@
taglib
prefix=
"f"
uri=
"http://www.springframework.org/tags/form"
%
>
<!DOCTYPE html>
<!DOCTYPE html>
<html>
<html>
<head>
<head>
<meta
charset=
"UTF-8"
>
<meta
charset=
"UTF-8"
>
<title>
Edycja danych produktu
</title>
<title>
Edycja danych produktu
</title>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"/styl.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"/styl.css"
>
</head>
</head>
<body>
<body>
<h1>
Edycja produktu
</h1>
<form
id=
"product-form"
method=
"post"
>
<c:choose>
<table
class=
"form"
>
<c:when
test=
"${not empty(product.productId)}"
>
<h1>
Edycja produktu nr ${product.productId}
</h1>
</c:when>
<c:otherwise>
<h1>
Edycja nowego produktu
</h1>
</c:otherwise>
</c:choose>
<f:form
id=
"product-form"
method=
"post"
modelAttribute=
"product"
>
<table
class=
"form-tab"
>
<tr>
<tr>
<td><label
for=
"productId"
>
Numer:
</
label></td>
<td><f:label
path=
"productId"
>
Numer:
</f:
label></td>
<td><input
name=
"productId"
placeholder=
"brak"
type=
"number"
readonly=
"readonly"
value=
"${product.productId}
"
/></td>
<td><f:input
path=
"productId"
placeholder=
"brak"
type=
"number"
readonly=
"true
"
/></td>
</tr>
</tr>
<tr>
<tr>
<td><label
for=
"productName"
>
Nazwa towaru:
</label></td>
<td><f:label
path=
"productName"
>
Nazwa towaru:
</f:label></td>
<td><input
name=
"productName"
placeholder=
"nazwa..."
type=
"text"
value=
"${product.productName}"
/>
<td><f:input
path=
"productName"
placeholder=
"nazwa..."
type=
"text"
/>
<f:errors
path=
"productName"
cssClass=
"form-error"
element=
"div"
/>
</td>
</td>
</tr>
</tr>
<tr>
<tr>
<td><label
for=
"price"
>
Cena:
</label></td>
<td><f:label
path=
"price"
>
Cena:
</f:label></td>
<td><input
name=
"price"
placeholder=
"12.90"
title=
"tu wpisz cenę"
type=
"number"
step=
"0.01"
value=
"${product.price}"
/>
<td><f:input
path=
"price"
placeholder=
"12.90"
type=
"number"
step=
"0.01"
/>
<f:errors
path=
"price"
cssClass=
"form-error"
element=
"div"
/>
</td>
</td>
</tr>
</tr>
<tr>
<tr>
<td><label
for=
"vat"
>
Stawka VAT:
</label></td>
<td><f:label
path=
"vat"
>
Stawka VAT:
</f:label></td>
<td><input
name=
"vat"
placeholder=
"0.23"
title=
"tu wpisz vat"
type=
"number"
step=
"0.01"
value=
"${product.vat}"
/>
<td><f:input
path=
"vat"
placeholder=
"0.23"
type=
"number"
step=
"0.01"
/>
<f:errors
path=
"vat"
cssClass=
"form-error"
element=
"div"
/>
</td>
</td>
</tr>
</tr>
<tr>
<tr>
<td><label
for=
"description"
>
Opis:
</
label></td>
<td><f:label
path=
"description"
>
Opis:
</f:
label></td>
<td><textarea
name=
"description"
rows=
"10"
cols=
"120"
>
${product.description}
</textarea
></td>
<td><f:textarea
path=
"description"
rows=
"10"
/
></td>
</tr>
</tr>
<tr>
<tr>
<td><button>
Zapisz
</
button></td>
<td><f:button>
Zapisz
</f:
button></td>
</tr>
</tr>
</table>
</table>
</form>
</f:form>
<div
class=
"action"
><a
href=
"/products"
>
powrót do listy produktów
</a></div>
<div
class=
"action"
><a
href=
"/"
>
powrót do spisu treści
</a></div>
<div><a
class=
"action"
href=
"/products"
>
powrót do listy produktów
</a></div>
<div><a
class=
"action"
href=
"/"
>
powrót do spisu treści
</a></div>
</body>
</body>
</html>
</html>
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