Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
bspastoriza19-esi-solutions
Project
Project
Details
Activity
Releases
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
Breixo Senra Pastoriza
bspastoriza19-esi-solutions
Commits
25685e70
Commit
25685e70
authored
Oct 25, 2025
by
Breixo Senra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Punto 4 BETA
parent
06edf8e1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
56 additions
and
12 deletions
+56
-12
PetDetailsManagedBean.java
...ain/java/es/uvigo/esei/xcs/jsf/PetDetailsManagedBean.java
+8
-8
VaccineManagedBean.java
...c/main/java/es/uvigo/esei/xcs/jsf/VaccineManagedBean.java
+27
-2
petDetails.xhtml
jsf/src/main/webapp/vet/petDetails.xhtml
+4
-2
vaccines.xhtml
jsf/src/main/webapp/vet/vaccines.xhtml
+17
-0
No files found.
jsf/src/main/java/es/uvigo/esei/xcs/jsf/PetDetailsManagedBean.java
View file @
25685e70
...
@@ -38,7 +38,7 @@ public class PetDetailsManagedBean implements Serializable{
...
@@ -38,7 +38,7 @@ public class PetDetailsManagedBean implements Serializable{
private
Pet
pet
;
private
Pet
pet
;
private
Long
selectedVaccineId
;
private
Long
selectedVaccineId
;
private
String
vaccinationDate
;
// yyyy-MM-dd
private
Date
vaccinationDate
;
// yyyy-MM-dd
private
List
<
Vaccine
>
allVaccines
;
private
List
<
Vaccine
>
allVaccines
;
@PostConstruct
@PostConstruct
...
@@ -69,33 +69,33 @@ public class PetDetailsManagedBean implements Serializable{
...
@@ -69,33 +69,33 @@ public class PetDetailsManagedBean implements Serializable{
this
.
selectedVaccineId
=
selectedVaccineId
;
this
.
selectedVaccineId
=
selectedVaccineId
;
}
}
public
String
getVaccinationDate
()
{
public
Date
getVaccinationDate
()
{
return
vaccinationDate
;
return
vaccinationDate
;
}
}
public
void
setVaccinationDate
(
String
vaccinationDate
)
{
public
void
setVaccinationDate
(
Date
vaccinationDate
)
{
this
.
vaccinationDate
=
vaccinationDate
;
this
.
vaccinationDate
=
vaccinationDate
;
}
}
// Método para vacunar
// Método para vacunar
public
String
vaccinate
()
{
public
String
vaccinate
()
{
if
(
selectedVaccineId
==
null
||
vaccinationDate
==
null
||
vaccinationDate
.
isEmpty
()
)
{
if
(
selectedVaccineId
==
null
||
vaccinationDate
==
null
/*|| vaccinationDate.isEmpty()*/
)
{
FacesContext
.
getCurrentInstance
().
addMessage
(
null
,
FacesContext
.
getCurrentInstance
().
addMessage
(
null
,
new
javax
.
faces
.
application
.
FacesMessage
(
"Debe seleccionar vacuna y fecha"
));
new
javax
.
faces
.
application
.
FacesMessage
(
"Debe seleccionar vacuna y fecha"
));
return
null
;
return
null
;
}
}
try
{
try
{
Date
date
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
).
parse
(
vaccinationDate
);
//
Date date = new SimpleDateFormat("yyyy-MM-dd").parse(vaccinationDate);
Vaccination
v
=
vaccinationService
.
create
(
pet
.
getId
(),
selectedVaccineId
,
d
ate
);
Vaccination
v
=
vaccinationService
.
create
(
pet
.
getId
(),
selectedVaccineId
,
vaccinationD
ate
);
// refrescar la mascota para mostrar la nueva vacunación
// refrescar la mascota para mostrar la nueva vacunación
this
.
pet
=
petService
.
get
(
pet
.
getId
());
this
.
pet
=
petService
.
get
(
pet
.
getId
());
FacesContext
.
getCurrentInstance
().
addMessage
(
null
,
FacesContext
.
getCurrentInstance
().
addMessage
(
null
,
new
javax
.
faces
.
application
.
FacesMessage
(
"Vacunación creada correctamente"
));
new
javax
.
faces
.
application
.
FacesMessage
(
"Vacunación creada correctamente"
));
}
catch
(
ParseException
e
)
{
}
/*
catch (ParseException e) {
FacesContext.getCurrentInstance().addMessage(null,
FacesContext.getCurrentInstance().addMessage(null,
new javax.faces.application.FacesMessage("Formato de fecha inválido"));
new javax.faces.application.FacesMessage("Formato de fecha inválido"));
}
catch
(
IllegalArgumentException
e
)
{
}
*/
catch
(
IllegalArgumentException
e
)
{
FacesContext
.
getCurrentInstance
().
addMessage
(
null
,
FacesContext
.
getCurrentInstance
().
addMessage
(
null
,
new
javax
.
faces
.
application
.
FacesMessage
(
e
.
getMessage
()));
new
javax
.
faces
.
application
.
FacesMessage
(
e
.
getMessage
()));
}
}
...
...
jsf/src/main/java/es/uvigo/esei/xcs/jsf/VaccineManagedBean.java
View file @
25685e70
package
es
.
uvigo
.
esei
.
xcs
.
jsf
;
package
es
.
uvigo
.
esei
.
xcs
.
jsf
;
import
java.io.Serializable
;
import
java.util.List
;
import
java.util.List
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.PostConstruct
;
import
javax.ejb.EJB
;
import
javax.ejb.EJB
;
import
javax.enterprise.context.RequestScoped
;
import
javax.enterprise.context.RequestScoped
;
import
javax.faces.view.ViewScoped
;
import
javax.inject.Named
;
import
javax.inject.Named
;
import
es.uvigo.esei.xcs.domain.entities.Vaccine
;
import
es.uvigo.esei.xcs.domain.entities.Vaccine
;
import
es.uvigo.esei.xcs.service.VaccineService
;
import
es.uvigo.esei.xcs.service.VaccineService
;
@Named
(
"vaccine"
)
@Named
(
"vaccine"
)
@RequestScoped
//@RequestScoped
public
class
VaccineManagedBean
{
@ViewScoped
public
class
VaccineManagedBean
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
@EJB
@EJB
private
VaccineService
vaccineService
;
private
VaccineService
vaccineService
;
...
@@ -38,6 +42,27 @@ public class VaccineManagedBean{
...
@@ -38,6 +42,27 @@ public class VaccineManagedBean{
vaccines
=
vaccineService
.
list
(
0
,
100
);
vaccines
=
vaccineService
.
list
(
0
,
100
);
}
}
private
Vaccine
selectedVaccine
;
// vacuna que vamos a editar
private
String
newName
;
// nuevo nombre para editar
public
Vaccine
getSelectedVaccine
()
{
return
selectedVaccine
;
}
public
void
setSelectedVaccine
(
Vaccine
selectedVaccine
)
{
this
.
selectedVaccine
=
selectedVaccine
;
if
(
selectedVaccine
!=
null
)
{
this
.
newName
=
selectedVaccine
.
getName
();
// precarga el nombre actual
}
}
public
String
getNewName
()
{
return
newName
;
}
public
void
setNewName
(
String
newName
)
{
this
.
newName
=
newName
;
}
public
void
editVaccine
()
{
if
(
selectedVaccine
!=
null
&&
newName
!=
null
&&
!
newName
.
trim
().
isEmpty
())
{
vaccineService
.
updateName
(
selectedVaccine
.
getId
(),
newName
);
vaccines
=
vaccineService
.
list
(
0
,
100
);
selectedVaccine
=
null
;
newName
=
null
;
}
}
private
void
clearForm
()
{
private
void
clearForm
()
{
name
=
null
;
name
=
null
;
...
...
jsf/src/main/webapp/vet/petDetails.xhtml
View file @
25685e70
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
<html
xmlns=
"http://www.w3.org/1999/xhtml"
<html
xmlns=
"http://www.w3.org/1999/xhtml"
xmlns:h=
"http://xmlns.jcp.org/jsf/html"
xmlns:h=
"http://xmlns.jcp.org/jsf/html"
xmlns:f=
"http://xmlns.jcp.org/jsf/core"
xmlns:f=
"http://xmlns.jcp.org/jsf/core"
xmlns:p=
"http://primefaces.org/ui"
xmlns:ui=
"http://xmlns.jcp.org/jsf/facelets"
>
xmlns:ui=
"http://xmlns.jcp.org/jsf/facelets"
>
<h:head>
<h:head>
<title>
Detalle de Mascota
</title>
<title>
Detalle de Mascota
</title>
...
@@ -38,9 +39,10 @@
...
@@ -38,9 +39,10 @@
</h:column>
</h:column>
</h:dataTable>
</h:dataTable>
<p:commandButton
value=
"Open Dialog"
/>
<h3>
Registrar nueva vacunación
</h3>
<h3>
Registrar nueva vacunación
</h3>
<h:form>
<h:form>
<!--<h:messages globalOnly="true" layout="table" style="color:red;" />-->
<h:panelGrid
columns=
"2"
>
<h:panelGrid
columns=
"2"
>
<h:outputLabel
value=
"Vacuna:"
for=
"vaccine"
/>
<h:outputLabel
value=
"Vacuna:"
for=
"vaccine"
/>
<h:selectOneMenu
value=
"#{petDetails.selectedVaccineId}"
id=
"vaccine"
>
<h:selectOneMenu
value=
"#{petDetails.selectedVaccineId}"
id=
"vaccine"
>
...
@@ -49,7 +51,7 @@
...
@@ -49,7 +51,7 @@
</h:selectOneMenu>
</h:selectOneMenu>
<h:outputLabel
value=
"Fecha:"
for=
"date"
/>
<h:outputLabel
value=
"Fecha:"
for=
"date"
/>
<
h:inputText
value=
"#{petDetails.vaccinationDate}"
id=
"date"
placeholder=
"yyyy-MM-dd"
/>
<
p:datePicker
id=
"date"
value=
"#{petDetails.vaccinationDate}"
pattern=
"yyyy-MM-dd"
showIcon=
"true"
/>
<h:commandButton
value=
"Vacunar"
action=
"#{petDetails.vaccinate}"
/>
<h:commandButton
value=
"Vacunar"
action=
"#{petDetails.vaccinate}"
/>
</h:panelGrid>
</h:panelGrid>
...
...
jsf/src/main/webapp/vet/vaccines.xhtml
View file @
25685e70
...
@@ -36,6 +36,8 @@
...
@@ -36,6 +36,8 @@
<h:form>
<h:form>
<h:commandButton
value=
"Eliminar"
action=
"#{vaccine.removeVaccine(v.id)}"
<h:commandButton
value=
"Eliminar"
action=
"#{vaccine.removeVaccine(v.id)}"
onclick=
"return confirm('¿Seguro que deseas eliminar esta vacuna?');"
/>
onclick=
"return confirm('¿Seguro que deseas eliminar esta vacuna?');"
/>
<h:commandButton
value=
"Editar"
action=
"#{vaccine.setSelectedVaccine(v)}"
onclick=
"return true;"
/>
</h:form>
</h:form>
</h:column>
</h:column>
</h:dataTable>
</h:dataTable>
...
@@ -89,5 +91,20 @@
...
@@ -89,5 +91,20 @@
<br/>
<br/>
<h:commandButton
value=
"Crear Vacuna"
action=
"#{vaccine.createVaccine}"
/>
<h:commandButton
value=
"Crear Vacuna"
action=
"#{vaccine.createVaccine}"
/>
</h:form>
</h:form>
<!--Formulario para editar vacuna-->
<h:form
rendered=
"#{not empty vaccine.selectedVaccine}"
>
<h3>
Editar vacuna #{vaccine.selectedVaccine.name}
</h3>
<h:panelGrid
columns=
"2"
cellpadding=
"5"
>
<h:outputLabel
value=
"Nuevo nombre:"
for=
"newName"
/>
<h:inputText
id=
"newName"
value=
"#{vaccine.newName}"
required=
"true"
/>
</h:panelGrid>
<br/>
<h:commandButton
value=
"Guardar cambios"
action=
"#{vaccine.editVaccine}"
/>
<h:commandButton
value=
"Cancelar"
action=
"#{vaccine.setSelectedVaccine(null)}"
immediate=
"true"
/>
</h:form>
</h:body>
</h: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