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
0
Merge Requests
0
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
Amparo Oliver
th-app-java
Commits
ba75ef2e
Commit
ba75ef2e
authored
Nov 23, 2021
by
Joel Florentin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
paginacion en las listas
parent
52226989
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
177 additions
and
91 deletions
+177
-91
curriculumsearch/src/main/java/com/roshka/controller/CargoController.java
+11
-6
curriculumsearch/src/main/java/com/roshka/controller/ConvocatoriaController.java
+11
-2
curriculumsearch/src/main/java/com/roshka/controller/PostulanteRRHHController.java
+1
-1
curriculumsearch/src/main/java/com/roshka/controller/TecnologiaController.java
+11
-5
curriculumsearch/src/main/java/com/roshka/repositorio/CargoRepository.java
+1
-1
curriculumsearch/src/main/java/com/roshka/repositorio/ConvocatoriaRepository.java
+3
-1
curriculumsearch/src/main/java/com/roshka/repositorio/TecnologiaRepository.java
+1
-1
curriculumsearch/src/main/webapp/jsp/cargos.jsp
+29
-29
curriculumsearch/src/main/webapp/jsp/convocatorias.jsp
+65
-18
curriculumsearch/src/main/webapp/jsp/layouts/base.jsp
+23
-0
curriculumsearch/src/main/webapp/jsp/postulantes.jsp
+1
-11
curriculumsearch/src/main/webapp/jsp/tecnologias.jsp
+20
-16
No files found.
curriculumsearch/src/main/java/com/roshka/controller/CargoController.java
View file @
ba75ef2e
...
...
@@ -34,13 +34,18 @@ public class CargoController {
@RequestMapping
(
"/cargos"
)
public
String
menuCargos
(
Model
model
,
@RequestParam
(
required
=
false
)
String
nombre
,
@RequestParam
(
defaultValue
=
"0"
)
Integer
nroPagina
)
{
final
Integer
CANTIDAD_POR_PAGINA
=
1
0
;
final
Integer
CANTIDAD_POR_PAGINA
=
1
;
Pageable
page
=
PageRequest
.
of
(
nroPagina
,
CANTIDAD_POR_PAGINA
,
Sort
.
by
(
"id"
));
Page
<
Cargo
>
CargoPag
=
cargoRepo
.
findAllCargo
(
page
);
List
<
Cargo
>
cargo
=
CargoPag
.
getContent
();
model
.
addAttribute
(
"pages"
,
CargoPag
.
getTotalPages
());
if
(
nombre
==
null
||
nombre
.
trim
().
isEmpty
())
model
.
addAttribute
(
"cargos"
,
cargo
);
else
model
.
addAttribute
(
"cargos"
,
cargoRepo
.
findByNombreContainingIgnoreCase
(
nombre
));
if
(
nombre
==
null
||
nombre
.
trim
().
isEmpty
())
{
Page
<
Cargo
>
CargoPag
=
cargoRepo
.
findAll
(
page
);
model
.
addAttribute
(
"cargos"
,
CargoPag
.
getContent
());
model
.
addAttribute
(
"pages"
,
CargoPag
.
getTotalPages
());
}
else
{
Page
<
Cargo
>
CargoPag
=
cargoRepo
.
findByNombreContainingIgnoreCase
(
nombre
,
page
);
model
.
addAttribute
(
"pages"
,
CargoPag
.
getTotalPages
());
model
.
addAttribute
(
"cargos"
,
CargoPag
.
getContent
());
}
return
"cargos"
;
}
...
...
curriculumsearch/src/main/java/com/roshka/controller/ConvocatoriaController.java
View file @
ba75ef2e
...
...
@@ -18,6 +18,10 @@ import org.hibernate.type.IntegerType;
import
org.hibernate.type.LongType
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.MessageSource
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.validation.BindingResult
;
...
...
@@ -43,12 +47,17 @@ public class ConvocatoriaController {
@RequestMapping
(
"/convocatorias"
)
public
String
menuConvocatorias
(
Model
model
,
RedirectAttributes
redirectAttrs
,
@RequestParam
(
required
=
false
)
Long
cargoId
,
@RequestParam
(
required
=
false
)
Integer
isOpen
//1: true, 0: false
@RequestParam
(
required
=
false
)
Integer
isOpen
,
//1: true, 0: false
@RequestParam
(
defaultValue
=
"0"
)
Integer
nroPagina
)
{
final
Integer
CANTIDAD_POR_PAGINA
=
1
;
Pageable
page
=
PageRequest
.
of
(
nroPagina
,
CANTIDAD_POR_PAGINA
,
Sort
.
by
(
"id"
));
model
.
addAttribute
(
"cargos"
,
cargoRepo
.
findAll
());
Page
<
ConvocatoriaCargo
>
convoPag
=
convoRepo
.
f1ndByCargoAndEstado
(
new
TypedParameterValue
(
LongType
.
INSTANCE
,
cargoId
),
new
Date
(),
new
TypedParameterValue
(
IntegerType
.
INSTANCE
,
isOpen
),
page
);
model
.
addAttribute
(
"convocatorias"
,
convoPag
.
getContent
());
model
.
addAttribute
(
"pages"
,
convoPag
.
getTotalPages
());
model
.
addAttribute
(
"convocatorias"
,
convoRepo
.
f1ndByCargoAndEstado
(
new
TypedParameterValue
(
LongType
.
INSTANCE
,
cargoId
),
new
Date
(),
new
TypedParameterValue
(
IntegerType
.
INSTANCE
,
isOpen
)));
//model.addAttribute("convocatorias",cargoId==null? convoRepo.findAll() : convoRepo.findByCargoId(cargoId));
return
"convocatorias"
;
}
...
...
curriculumsearch/src/main/java/com/roshka/controller/PostulanteRRHHController.java
View file @
ba75ef2e
...
...
@@ -100,7 +100,7 @@ public class PostulanteRRHHController {
@RequestParam
(
required
=
false
)
Long
convId
,
@RequestParam
(
defaultValue
=
"0"
)
Integer
nroPagina
)
throws
IOException
{
final
Integer
CANTIDAD_POR_PAGINA
=
5
;
final
Integer
CANTIDAD_POR_PAGINA
=
1
;
Pageable
page
=
PageRequest
.
of
(
nroPagina
,
CANTIDAD_POR_PAGINA
,
Sort
.
by
(
"id"
));
model
.
addAttribute
(
"tecnologias"
,
tecRepo
.
findAll
());
model
.
addAttribute
(
"disponibilidades"
,
Disponibilidad
.
values
());
...
...
curriculumsearch/src/main/java/com/roshka/controller/TecnologiaController.java
View file @
ba75ef2e
...
...
@@ -47,11 +47,17 @@ public String addtecnologiaView(Model model,@PathVariable(required = false) Long
public
String
menuTecnologias
(
Model
model
,
@RequestParam
(
required
=
false
)
String
nombre
,
@RequestParam
(
defaultValue
=
"0"
)
Integer
nroPagina
)
{
final
Integer
CANTIDAD_POR_PAGINA
=
10
;
Pageable
page
=
PageRequest
.
of
(
nroPagina
,
CANTIDAD_POR_PAGINA
,
Sort
.
by
(
"id"
));
Page
<
Tecnologia
>
tecnologiaPag
=
tecRepo
.
findAllTecnologia
(
page
);
List
<
Tecnologia
>
tecnologia
=
tecnologiaPag
.
getContent
();
model
.
addAttribute
(
"pages"
,
tecnologiaPag
.
getTotalPages
());
if
(
nombre
==
null
||
nombre
.
trim
().
isEmpty
())
model
.
addAttribute
(
"tecnologias"
,
tecnologia
);
else
model
.
addAttribute
(
"tecnologias"
,
tecRepo
.
findByNombreContainingIgnoreCase
(
nombre
));
if
(
nombre
==
null
||
nombre
.
trim
().
isEmpty
())
{
Page
<
Tecnologia
>
tecnologiaPag
=
tecRepo
.
findAllTecnologia
(
page
);
model
.
addAttribute
(
"tecnologias"
,
tecnologiaPag
.
getContent
());
model
.
addAttribute
(
"pages"
,
tecnologiaPag
.
getTotalPages
());
}
else
{
Page
<
Tecnologia
>
tecnologiaPag
=
tecRepo
.
findByNombreContainingIgnoreCase
(
nombre
,
page
);
model
.
addAttribute
(
"pages"
,
tecnologiaPag
.
getTotalPages
());
model
.
addAttribute
(
"tecnologias"
,
tecnologiaPag
.
getContent
());
}
return
"tecnologias"
;
}
...
...
curriculumsearch/src/main/java/com/roshka/repositorio/CargoRepository.java
View file @
ba75ef2e
...
...
@@ -10,7 +10,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
import
org.springframework.data.jpa.repository.Query
;
public
interface
CargoRepository
extends
JpaRepository
<
Cargo
,
Long
>{
public
List
<
Cargo
>
findByNombreContainingIgnoreCase
(
String
nombr
e
);
public
Page
<
Cargo
>
findByNombreContainingIgnoreCase
(
String
nombre
,
Pageable
pageabl
e
);
public
boolean
existsByNombreIgnoreCase
(
String
nombre
);
...
...
curriculumsearch/src/main/java/com/roshka/repositorio/ConvocatoriaRepository.java
View file @
ba75ef2e
...
...
@@ -6,6 +6,8 @@ import java.util.List;
import
com.roshka.modelo.ConvocatoriaCargo
;
import
org.hibernate.jpa.TypedParameterValue
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Query
;
...
...
@@ -16,7 +18,7 @@ public interface ConvocatoriaRepository extends JpaRepository<ConvocatoriaCargo,
//@Query(value="selec x from ConvocatoriaCargo x where (x.fechaFinal > ?1)",nativeQuery = true)
//public List<ConvocatoriaCargo> findConvocatoriaCargoByCargo(Date fechaFinal);
@Query
(
"select c from ConvocatoriaCargo c where ( ?1 is null and ?3 is null) or ( ( ( ((c.fechaFin > ?2 or c.fechaFin=null) and ?3 = 1) or ((c.fechaFin < ?2 ) and ?3 = 0)) or ?3 is null ) and (c.cargoId = ?1 or ?1 is null) )"
)
public
List
<
ConvocatoriaCargo
>
f1ndByCargoAndEstado
(
TypedParameterValue
cargoId
,
Date
fecha
,
TypedParameterValue
isOpen
);
public
Page
<
ConvocatoriaCargo
>
f1ndByCargoAndEstado
(
TypedParameterValue
cargoId
,
Date
fecha
,
TypedParameterValue
isOpen
,
Pageable
page
);
@Query
(
"SELECT c FROM ConvocatoriaCargo c WHERE (cargoId=?1)"
)
public
List
<
ConvocatoriaCargo
>
filtrarConvocatoriasPorCargo
(
Long
cargoId
);
...
...
curriculumsearch/src/main/java/com/roshka/repositorio/TecnologiaRepository.java
View file @
ba75ef2e
...
...
@@ -11,7 +11,7 @@ import com.roshka.modelo.Tecnologia;
public
interface
TecnologiaRepository
extends
JpaRepository
<
Tecnologia
,
Long
>
{
public
List
<
Tecnologia
>
findByNombreContainingIgnoreCase
(
String
nombr
e
);
public
Page
<
Tecnologia
>
findByNombreContainingIgnoreCase
(
String
nombre
,
Pageable
pageabl
e
);
public
boolean
existsByNombreIgnoreCase
(
String
nombre
);
...
...
curriculumsearch/src/main/webapp/jsp/cargos.jsp
View file @
ba75ef2e
...
...
@@ -9,16 +9,25 @@ contentType="text/html;charset=UTF-8" language="java" %>
<h2>Lista de cargos</h2>
<div>
<form>
<label for="cargos">Nombre:</label>
<input
type="text"
name="nombre"
id="nombre"
value="${param.nombre}"
/>
<input type="submit" value="Buscar" />
<div class="row justify-content-start gy-2">
<div class="col-auto">
<input
class="form-control"
placeholder="Nombre"
type="text"
name="nombre"
id="nombre"
value="${param.nombre}"
/>
</div>
<div class="col-auto">
<input type="submit" class="btn btn-primary" value="Buscar" />
</div>
</div>
</form>
<a href="/cargo">Agregar Nuevo Cargo</a>
</div>
<div class="card text-dark bg-light mt-3">
...
...
@@ -48,16 +57,16 @@ contentType="text/html;charset=UTF-8" language="java" %>
</table>
</div>
</div>
</div
>
<div class="card-footer"
>
<div
>
<nav aria-label="Page navigation example
">
<ul class="pagination
">
<c:forEach begin="1" end="${pages}" var="nro"
>
<
li class="page-item ${(param.nroPagina == null and nro == 1) or param.nroPagina == nro-1 ? 'active' : ''}"><a class="page-link" href="javascript:buscarPagina(${nro})">${nro}</a></li
>
</
c:forEach
>
</
ul
>
</
na
v>
<div class="card-footer"
>
<div
>
<nav aria-label="Page navigation example"
>
<ul class="pagination
">
<c:forEach begin="1" end="${pages}" var="nro
">
<li class="page-item ${(param.nroPagina == null and nro == 1) or param.nroPagina == nro-1 ? 'active' : ''}"><a class="page-link" href="javascript:buscarPagina(${nro})">${nro}</a></li
>
<
/c:forEach
>
</
ul
>
</
nav
>
</
di
v>
</div>
</div>
</div>
...
...
@@ -65,16 +74,7 @@ contentType="text/html;charset=UTF-8" language="java" %>
</layout:put>
<layout:put block="scripts" type="APPEND">
<script>
function buscarPagina(nro){
nro--
const aBuscar = 'nroPagina='+nro
if(!location.search) location.search = "?"+aBuscar
const inicial = location.search.search(aBuscar);
if(inicial==-1){//si no se encuentra y hay otros queries
location.search = "&"+aBuscar
}
location.search.replace('nroPagina=',aBuscar)
}
</script>
</layout:put>
</layout:extends>
curriculumsearch/src/main/webapp/jsp/convocatorias.jsp
View file @
ba75ef2e
...
...
@@ -5,29 +5,65 @@
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<layout:extends name="layouts/base.jsp">
<layout:put block="cssDeclaracion" type="APPEND"></layout:put>
<layout:put block="cssDeclaracion" type="APPEND">
<style>
label {
width: auto;
}
</style>
</layout:put>
<layout:put block="contents" type="REPLACE">
<h2>Lista de convocatorias</h2>
<div>
<form>
<label for="cargos">Cargos:</label>
<select name="cargoId" id="cargos">
<option value="">Todos los cargos</option>
<c:forEach items="${cargos}" var="cargo">
<option value="${cargo.id}" ${param.cargoId == cargo.id ? "selected" : ""} >${cargo.nombre}</option>
</c:forEach>
</select>
Estado:
<input type="radio" id="cualquiera" name="isOpen" checked value="">
<label for="abierto">Cualquiera</label><br>
<input type="radio" id="abierto" name="isOpen" value="1">
<label for="abierto">Abierto</label><br>
<input type="radio" id="cerrado" name="isOpen" value="0">
<label for="cerrado">Cerrado</label><br>
<input type="submit" value="Buscar">
<div class="row row-cols-2 gy-2">
<div class="col-auto">
<div class="row">
<div class="col-auto">
<label class="form-label" for="cargos">Cargos:</label>
</div>
<div class="col">
<select class="form-select form-select-sm" name="cargoId" id="cargos">
<option value="">Todos los cargos</option>
<c:forEach items="${cargos}" var="cargo">
<option value="${cargo.id}" ${param.cargoId == cargo.id ? "selected" : ""} >${cargo.nombre}</option>
</c:forEach>
</select>
</div>
</div>
</div>
<div class="col-auto">
<label for="form-check-label">Estado: </label>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="cualquiera" name="isOpen" checked value="">
<label class="form-check-label" for="cualquiera">Cualquiera</label><br>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="abierto" name="isOpen" value="1">
<label class="form-check-label" for="abierto">Abierto</label><br>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" id="cerrado" name="isOpen" value="0">
<label class="form-check-label" for="cerrado">Cerrado</label><br>
</div>
</div>
<div class="col-auto">
<input type="submit" class="btn btn-primary btn-sm" value="Buscar">
</div>
</div>
</form>
</div>
<a href="/convocatoria">Agregar Nueva Convocatoria</a>
<c:if test="${SUCCESS_MESSAGE != null}">
<div id="status_message">${SUCCESS_MESSAGE}</div>
</c:if>
...
...
@@ -55,7 +91,7 @@
<td><fmt:formatDate value="${convocatoria.getFechaInicio()}" pattern="dd-MM-yyyy" /></td>
<td><fmt:formatDate value="${convocatoria.getFechaFin()}" pattern="dd-MM-yyyy" /></td>
<td><a href="/postulantes?convId=${convocatoria.id}">Ver postulantes</a></td>
<td><
button onclick=window.location.href="/convocatoria/${convocatoria.id}">Cerrar convocatoria</button
></td>
<td><
a class="btn btn-secondary" href="/convocatoria/${convocatoria.id}">Cerrar convocatoria</a
></td>
</tr>
</c:forEach>
...
...
@@ -65,6 +101,17 @@
</table>
</div>
</div>
<div class="card-footer">
<div>
<nav aria-label="Page navigation example">
<ul class="pagination">
<c:forEach begin="1" end="${pages}" var="nro">
<li class="page-item ${(param.nroPagina == null and nro == 1) or param.nroPagina == nro-1 ? 'active' : ''}"><a class="page-link" href="javascript:buscarPagina(${nro})">${nro}</a></li>
</c:forEach>
</ul>
</nav>
</div>
</div>
</div>
</layout:put>
...
...
curriculumsearch/src/main/webapp/jsp/layouts/base.jsp
View file @
ba75ef2e
...
...
@@ -78,6 +78,29 @@
</div>
<layout:block
name=
"scripts"
>
<script>
function
buscarPagina
(
nro
){
nro
--
const
queries
=
location
.
search
.
split
(
"&"
);
let
existe
=
false
;
if
(
location
.
search
.
length
==
0
)
location
.
search
=
"?nroPagina="
+
nro
;
let
fullquery
=
""
;
for
(
const
query
of
queries
)
{
let
[
key
,
value
]
=
query
.
split
(
"="
);
if
(
key
.
includes
(
'nroPagina'
)){
fullquery
+=
key
+
"="
+
nro
+
"&"
;
existe
=
true
;
}
else
{
fullquery
+=
key
+
"="
+
value
+
"&"
;
}
}
if
(
!
existe
)
fullquery
+=
"nroPagina"
+
"="
+
nro
+
"&"
;
location
.
search
=
fullquery
.
substring
(
0
,
fullquery
.
length
-
1
);
}
</script>
</layout:block>
<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>
...
...
curriculumsearch/src/main/webapp/jsp/postulantes.jsp
View file @
ba75ef2e
...
...
@@ -280,17 +280,7 @@
}
function buscarPagina(nro){
nro--
const aBuscar = 'nroPagina='+nro
if(!location.search) location.search = aBuscar
const inicial = location.search.search(aBuscar);
if(inicial==-1){//si no se encuentra y hay otros queries
location.search = "&"+aBuscar;
}
location.search.replace('nroPagina=',aBuscar)
console.log(location.search)
}
const tecId = document.querySelector("#tecId");
const lvlTec = document.querySelector("#lvlTec");
tecId.addEventListener('change',habilitarLvlTec);
...
...
curriculumsearch/src/main/webapp/jsp/tecnologias.jsp
View file @
ba75ef2e
...
...
@@ -9,11 +9,26 @@
<div>
<form>
<label for="tecnologias">Nombre:</label>
<input type="text" name="nombre" id="nombre" value="${param.nombre}"/>
<input type="submit" value="Buscar">
<div class="row justify-content-start gy-2">
<div class="col-auto">
<input
class="form-control"
placeholder="Nombre"
type="text"
name="nombre"
id="nombre"
value="${param.nombre}"
/>
</div>
<div class="col-auto">
<input type="submit" class="btn btn-primary" value="Buscar" />
</div>
</div>
</form>
<a href="/tecnologia">Agregar Nueva Tecnologia</a>
</div>
<div class="card text-dark bg-light mt-3">
...
...
@@ -61,17 +76,6 @@
</layout:put>
<layout:put block="scripts" type="APPEND">
<script>
function buscarPagina(nro){
nro--
const aBuscar = 'nroPagina='+nro
if(!location.search) location.search = "?"+aBuscar
const inicial = location.search.search(aBuscar);
if(inicial==-1){//si no se encuentra y hay otros queries
location.search = "&"+aBuscar
}
location.search.replace('nroPagina=',aBuscar)
}
</script>
</layout:put>
</layout:extends>
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