Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
th-app-java
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
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Oscar Enrique Gonzalez Escurra
th-app-java
Commits
e88779db
Commit
e88779db
authored
Nov 08, 2021
by
Javier Ferreira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
form para agregar y editar tecnologia
parent
b9ac88e2
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
9 deletions
+79
-9
curriculumsearch/src/main/java/com/roshka/controller/TecnologiaController.java
+25
-7
curriculumsearch/src/main/java/com/roshka/repositorio/TecnologiaRepository.java
+3
-1
curriculumsearch/src/main/webapp/jsp/tecnologia-form.jsp
+1
-1
curriculumsearch/src/main/webapp/jsp/tecnologias.jsp
+50
-0
No files found.
curriculumsearch/src/main/java/com/roshka/controller/TecnologiaController.java
View file @
e88779db
...
@@ -6,10 +6,13 @@ import com.roshka.repositorio.TecnologiaRepository;
...
@@ -6,10 +6,13 @@ import com.roshka.repositorio.TecnologiaRepository;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.ui.Model
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
@Controller
@Controller
public
class
TecnologiaController
{
public
class
TecnologiaController
{
...
@@ -23,15 +26,30 @@ public TecnologiaController(TecnologiaRepository tecRepo){
...
@@ -23,15 +26,30 @@ public TecnologiaController(TecnologiaRepository tecRepo){
}
}
@GetMapping
(
"/tecnologia"
)
@GetMapping
(
path
=
{
"/tecnologia"
,
"/tecnologia/{id}"
})
public
String
addtecnologiaView
(
Model
model
)
{
public
String
addtecnologiaView
(
Model
model
,
@PathVariable
(
required
=
false
)
Long
id
)
{
model
.
addAttribute
(
"tecnologia"
,
new
Tecnologia
());
if
(
id
==
null
)
model
.
addAttribute
(
"tecnologia"
,
new
Tecnologia
());
else
model
.
addAttribute
(
"tecnologia"
,
tecRepo
.
getById
(
id
));
return
"tecnologia-form"
;
return
"tecnologia-form"
;
}
}
@PostMapping
(
"/tecnologia"
)
public
String
addtecnologia
(
@ModelAttribute
(
"tecnologia"
)
Tecnologia
tecnologia
)
{
@RequestMapping
(
"/tecnologias"
)
tecRepo
.
save
(
tecnologia
);
public
String
menuTecnologias
(
Model
model
,
@RequestParam
(
required
=
false
)
String
nombre
)
{
if
(
nombre
==
null
||
nombre
.
trim
().
isEmpty
())
model
.
addAttribute
(
"tecnologias"
,
tecRepo
.
findAll
());
else
model
.
addAttribute
(
"tecnologias"
,
tecRepo
.
findByNombreContainingIgnoreCase
(
nombre
));
return
"tecnologias"
;
}
@PostMapping
(
path
=
{
"/tecnologia"
,
"/tecnologia/{id}"
})
public
String
addtecnologia
(
@ModelAttribute
Tecnologia
tecnologia
,
BindingResult
result
,
@PathVariable
(
required
=
false
)
Long
id
)
{
if
(
result
.
hasErrors
());
if
(
id
!=
null
)
tecnologia
.
setId
(
id
);
tecRepo
.
save
(
tecnologia
);
System
.
out
.
println
(
tecnologia
.
getNombre
());
return
"redirect:/"
;
return
"redirect:/"
;
}
}
...
...
curriculumsearch/src/main/java/com/roshka/repositorio/TecnologiaRepository.java
View file @
e88779db
...
@@ -2,9 +2,11 @@ package com.roshka.repositorio;
...
@@ -2,9 +2,11 @@ package com.roshka.repositorio;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
java.util.List
;
import
com.roshka.modelo.Tecnologia
;
import
com.roshka.modelo.Tecnologia
;
public
interface
TecnologiaRepository
extends
JpaRepository
<
Tecnologia
,
Long
>
{
public
interface
TecnologiaRepository
extends
JpaRepository
<
Tecnologia
,
Long
>
{
public
List
<
Tecnologia
>
findByNombreContainingIgnoreCase
(
String
nombre
);
}
}
curriculumsearch/src/main/webapp/jsp/tecnologia-form.jsp
View file @
e88779db
...
@@ -23,7 +23,7 @@
...
@@ -23,7 +23,7 @@
</head>
</head>
<body>
<body>
<form:form
action=
"/tecnologia
"
method=
"post"
modelAttribute=
"tecnologia"
>
<form:form
action=
"/tecnologia
/${tecnologia.id == null ? '' : tecnologia.id}"
method=
"post"
modelAttribute=
"tecnologia"
>
<form:label
path=
"nombre"
>
name:
</form:label>
<form:input
type=
"text"
path=
"nombre"
/>
<form:label
path=
"nombre"
>
name:
</form:label>
<form:input
type=
"text"
path=
"nombre"
/>
<input
type=
"submit"
value=
"submit"
/>
<input
type=
"submit"
value=
"submit"
/>
</form:form>
</form:form>
...
...
curriculumsearch/src/main/webapp/jsp/tecnologias.jsp
0 → 100644
View file @
e88779db
<
%@
taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%
>
<
%@
taglib
prefix=
"form"
uri=
"http://www.springframework.org/tags/form"
%
>
<
%@
page
contentType=
"text/html;charset=UTF-8"
language=
"java"
%
>
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
>
<title>
Tecnologia
</title>
<link
href=
"https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
rel=
"stylesheet"
integrity=
"sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
crossorigin=
"anonymous"
>
<script
src=
"https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"
integrity=
"sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p"
crossorigin=
"anonymous"
></script>
</head>
<body
class=
"container"
>
<div>
<form>
<label
for=
"tecnologias"
>
Nombre:
</label>
<input
type=
"text"
name=
"nombre"
id=
"nombre"
value=
"${param.nombre}"
/>
<input
type=
"submit"
value=
"Buscar"
>
</form>
<a
href=
"/tecnologia"
>
Agregar Nueva Tecnologia
</a>
</div>
<div>
<table
class=
"table"
>
<thead>
<tr>
<th
scope=
"col"
>
#
</th>
<th
scope=
"col"
>
Tecnologia
</th>
</tr>
</thead>
<tbody>
<c:forEach
items=
"${tecnologias}"
var=
"tecnologia"
varStatus=
"sta"
>
<tr>
<th
scope=
"row"
>
${sta.index+1}
</th>
<td>
${tecnologia.getNombre()}
</td>
<td><a
href=
"/tecnologia/${tecnologia.id}"
>
Editar tecnologia
</a></td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</body>
</html>
\ No newline at end of file
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