Commit 941c6eaa by Patryk Czarnik

f:form

parent 9e1482a8
...@@ -44,7 +44,7 @@ public class ProductController { ...@@ -44,7 +44,7 @@ public class ProductController {
} }
@GetMapping("/products/new") @GetMapping("/products/new")
public String newProduct() { public String newProduct(Product product) {
return "product_form"; return "product_form";
} }
......
<%@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="http://java.sun.com/jsp/jstl/core"%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@taglib prefix="f" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
...@@ -18,36 +20,39 @@ ...@@ -18,36 +20,39 @@
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
<form id="product-form" method="post"> <f:form id="product-form" method="post" modelAttribute="product">
<table class="form"> <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"/>
</td> <f:errors path="productName" cssClass="form-error" element="div"/>
</tr> </td>
<tr> </tr>
<td><label for="price">Cena:</label></td> <tr>
<td><input name="price" placeholder="12.90" title="tu wpisz cenę" type="number" step="0.01" value="${product.price}"/> <td><f:label path="price">Cena:</f:label></td>
</td> <td><f:input path="price" placeholder="12.90" type="number" step="0.01"/>
</tr> <f:errors path="price" cssClass="form-error" element="div"/>
<tr> </td>
<td><label for="vat">Stawka VAT:</label></td> </tr>
<td><input name="vat" placeholder="0.23" title="tu wpisz vat" type="number" step="0.01" value="${product.vat}"/> <tr>
</td> <td><f:label path="vat">Stawka VAT:</f:label></td>
</tr> <td><f:input path="vat" placeholder="0.23" type="number" step="0.01"/>
<tr> <f:errors path="vat" cssClass="form-error" element="div"/>
<td><label for="description">Opis:</label></td> </td>
<td><textarea name="description" rows="10" cols="120">${product.description}</textarea></td> </tr>
</tr> <tr>
<tr> <td><f:label path="description">Opis:</f:label></td>
<td><button>Zapisz</button></td> <td><f:textarea path="description" rows="10"/></td>
</tr> </tr>
</table> <tr>
</form> <td><f:button>Zapisz</f:button></td>
</tr>
</table>
</f:form>
<c:if test="${not empty(errors)}"> <c:if test="${not empty(errors)}">
<div class="error"> <div class="error">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment