Anda di halaman 1dari 55

Luis Ordez Brbara Barragn | Arquitectura Orientada a

Gestin de
Biblioteca

Servicios |

USANDO JAVA SERVER FACES

Introduccin
1
Java
Server
Faces (JSF)
es
una
tecnologa
y
framework
para
aplicaciones Java basadas en web que simplifica el desarrollo de interfaces de
usuario en aplicaciones Java EE. JSF usa JavaServer Pages (JSP) como la tecnologa
que permite hacer el despliegue de las pginas, pero tambin se puede acomodar a
otras tecnologas como XUL (acrnimo de XML-based User-interface Language,
lenguaje basado en XML para la interfaz de usuario).

JSF incluye:
Un conjunto de APIs para representar componentes de una interfaz de usuario
y administrar su estado, manejar eventos, validar entrada, definir un esquema
de navegacin de las pginas y dar soporte para internacionalizacin y
accesibilidad.
Un conjunto por defecto de componentes para la interfaz de usuario.
Dos bibliotecas de etiquetas personalizadas para JavaServer Pages que
permiten expresar una interfaz JavaServer Faces dentro de una pgina JSP.
Un modelo de eventos en el lado del servidor.
Administracin de estados.
Beans administrados.

Definicin de objetivos
1. Crear una base de datos usando MySQL Workbench 6.0
2. Crear un Servicio Web con en IDE NetBeans 7.4, que a sus vez gestione la
base de datos antes mencionada
3. Crear un Cliente JSF que consumir el Servicio Web antes creado

Anlisis de los requisitos y su viabilidad


El proyecto que generaremos automatizar conexin, insercin, actualizacin y
consulta de los datos generados por los movimientos realizados en la gestin de una
biblioteca.
Los servicios que ofrecer nuestra aplicacin sern:
1. Ingreso y consulta de libros
1 http://es.wikipedia.org/wiki/JavaServer_Faces

2.
3.
4.
5.
6.

Ingreso y consulta de usuarios de la biblioteca


Ingreso y consulta de nuevos ejemplares de libros existentes
Ingreso y consulta de prstamos de ejemplares
Ingreso y consulta de devoluciones de ejemplares
Reporte del nmero de ejemplares registrados versus el nmero de
ejemplares disponibles para prstamo

Para lograr el objetivo planteado crearemos:


1. Una base de datos MySQL: bddbiblioteca con MySQL Workbench 6.0
2. Un servicio web: ZServer con Java NetBeans 7.4
3. Un cliente JSF: .BibliotecaCliente con Java NetBeans 7.4

Diseo y Creacin de la Base de Datos


DESCRIPCIN:
La base de datos relacional bddbiblioteca que se gestionar a travs de la
aplicacin consta de cuatro tablas:
1. libro
Registrar ttulo, autor, tema y ao de publicacin del libro. Tambin
desencadenar un trigger luego de insertar un nuevo registro haciendo que se
registre un nuevo ejemplar en la tabla ejemplar (luego mencionada),
poniendo en el campo ejemplar.disponible un 1(uno), para indicar
disponibilidad de prstamo.
2. ejemplar
Registrar ejemplares de libros y manejar disponibilidad de prstamo
mediante el atributo disponible, si el campo registra 1(uno) est disponible y
no lo est si registra 0(cero)
3. prestamo
Registrar prstamos y devoluciones de libros interactuando con las tablas
socio (luego descrita) y ejemplar. Para indicar prstamo el campo estado
registrar 1(uno) y para indicar devolucin registrar 0(cero).
4. socio
Registrar nombre, apellido, domicilio y telfono del usuario de la biblioteca.
Durante el desarrollo del proyecto socio o usuario se manejan como
sinnimos.

DIAGRAMA ENTIDAD-RELACIN:

SCRIPT DE LA BASE DE DATOS:


-- Base de Datos bddbiblioteca
CREATE DATABASE IF NOT EXISTS `bddbiblioteca`;
USE `bddbiblioteca`;
--- Tabla `libro`
DROP TABLE IF EXISTS `libro`;
CREATE TABLE `libro` (
`id_libro` int(11) NOT NULL,
`titulo` varchar(100) DEFAULT NULL,
`autor` varchar(50) DEFAULT NULL,
`tema` varchar(50) DEFAULT NULL,
`ao` int(11) DEFAULT NULL,
PRIMARY KEY (`id_libro`),
UNIQUE KEY `titulo_UNIQUE` (`titulo`)
);
--- Tabla `ejemplar`
DROP TABLE IF EXISTS `ejemplar`;
CREATE TABLE `ejemplar` (
`id_ejemplar` int(11) NOT NULL AUTO_INCREMENT,
`id_libro` int(11) NOT NULL DEFAULT '0',
`disponible` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`id_ejemplar`,`id_libro`),
KEY `id_libro` (`id_libro`),
CONSTRAINT `ejemplar_ibfk_1` FOREIGN KEY (`id_libro`) REFERENCES `libro` (`id_libro`)
);
--- Tabla `socio`
DROP TABLE IF EXISTS `socio`;
CREATE TABLE `socio` (
`id_socio` int(11) NOT NULL,
`nombre` varchar(50) DEFAULT NULL,
`apellido` varchar(50) DEFAULT NULL,
`domicilio` varchar(50) DEFAULT NULL,
`telefono` varchar(10) DEFAULT NULL,
PRIMARY KEY (`id_socio`)
);
--- Tabla `prestamo`
DROP TABLE IF EXISTS `prestamo`;
CREATE TABLE `prestamo` (
`fecha` date NOT NULL DEFAULT '0000-00-00',
`id_ejemplar` int(11) NOT NULL DEFAULT '0',

`id_libro` int(11) NOT NULL DEFAULT '0',


`id_socio` int(11) NOT NULL DEFAULT '0',
`estado` tinyint(1) DEFAULT NULL,
PRIMARY KEY (`fecha`,`id_ejemplar`,`id_libro`,`id_socio`),
KEY `id_libro` (`id_libro`),
KEY `id_ejemplar` (`id_ejemplar`),
KEY `id_socio` (`id_socio`),
CONSTRAINT `prestamo_ibfk_1` FOREIGN KEY (`id_libro`) REFERENCES `ejemplar` (`id_libro`),
CONSTRAINT `prestamo_ibfk_2` FOREIGN KEY (`id_ejemplar`) REFERENCES `ejemplar`
(`id_ejemplar`),
CONSTRAINT `prestamo_ibfk_3` FOREIGN KEY (`id_socio`) REFERENCES `socio` (`id_socio`)
);
--- Trigger insertarLibro
create trigger insertarLibro after
insert on libro for each row
insert into ejemplar(id_libro, disponible)
values (new.id_libro, '1');

CREACIN DE LA BASE DE DATOS:


Para la creacin de la base de datos se ejecuta el script en el ambiente de consultas
de MySQL WorkBench 6.0.

Creacin y Despliegue del Servicio Web


Para la creacin del servicio web procedemos de la siguiente forma:
1.
2.
3.
4.
5.
6.
7.
8.
9.

Ingresamos al IDE de NetBeans 7.4


Clic en Archivo
Clic en Proyecto Nuevo
Escogemos en Categoras: Java Web
Seleccionamos en Proyectos: Web Applicaton
Clic en Siguiente>
Digitamos ZServer en Project Name
Clic en Siguiente
Verificamos que:
a. El servidor sea GlassFish Server 4.0
b. La versin de Java EE sea Java EE 7 Web
10. Clic en Terminar
11. Creado el proyecto hacemos clic derecho sobre ZServer que se encuentra en
el explorador de proyectos, seleccionamos Nuevo/Web Service
12.En Nombre de Clase digitamos: bibliotecaws, en Paquete digitamos:
biblioteca.ec y damos clic en Terminar
13.Nuevamente en damos clic derecho sobre ZServer y seleccionamos
Nuevo/Java Class
14.En Nombre de la Clase digitamos: lista, en Paquete digitamos:
identidades.ec y damos clic en Terminar
En ste punto el servicio web se mostrar de la siguiente forma:

15. Dentro de lista.java digitaremos el siguiente cdigo (para generar


automticamente las finciones GET y SET: damos clic derecho sobre los
atributos seleccionados y seleccionamos Inserta cdigo y luego
seleccionamos Getter y Setter ):

1.

package identidades.ec;

2.
3. /*
4.
* @author LuisFernando
5.
*/
6. public class lista {
7.
8.
int _id_libro;
9.
String _titulo;
10.
String _autor;
11.
String _tema;
12.
int _ao;
13.
14.
int _disponibles;
15.
int _ejemplares;

16.
17.
18.
19.
20.
21.

int _id_socio;
String _nombre;
String _apellido;
String _domicilio;
String _telefono;

22.
23.
24.
25.

26.
27.
28.
29.
30.

public String getFecha() {


return _fecha;
}
public void setFecha(String _fecha) {
this._fecha = _fecha;
}
String _fecha;

31.
32.
33.
34.

35.
36.
37.
38.
39.
40.
41.
42.
43.
44.

public int getId_ejemplar() {


return _id_ejemplar;
}
public void setId_ejemplar(int _id_ejemplar) {
this._id_ejemplar = _id_ejemplar;
}
int _id_ejemplar;
public int getId_libro() {
return _id_libro;
}

45.
46.
47.

public void setId_libro(int _id_libro) {


this._id_libro = _id_libro;

48.

49.
50.
51.
52.

53.
54.
55.
56.

public String getTitulo() {


return _titulo;
}
public void setTitulo(String _titulo) {
this._titulo = _titulo;
}

57.
58.
59.
60.

61.
62.
63.
64.

public String getAutor() {


return _autor;
}
public void setAutor(String _autor) {
this._autor = _autor;
}

65.
66.
67.
68.

69.
70.
71.
72.

public String getTema() {


return _tema;
}
public void setTema(String _tema) {
this._tema = _tema;
}

73.
74.
75.
76.

77.
78.
79.
80.

public int getAo() {


return _ao;
}
public void setAo(int _ao) {
this._ao = _ao;
}

81.
82.
83.
84.

85.
86.
87.
88.

public int getDisponibles() {


return _disponibles;
}
public void setDisponibles(int _disponibles) {
this._disponibles = _disponibles;
}

89.
90.
91.
92.

93.

94.
95.
96.
97.
98.
99.
100.

public int getEjemplares() {


return _ejemplares;
}
public void setEjemplares(int _ejemplares) {
this._ejemplares = _ejemplares;
}
public int getId_socio() {
return _id_socio;
}

101.
102.
103.
104.

105.
106.
107.
108.

public void setId_socio(int _id_socio) {


this._id_socio = _id_socio;
}
public String getNombre() {
return _nombre;
}

109.
110.
111.
112.

public void setNombre(String _nombre) {


this._nombre = _nombre;
}

113.
114.
115.
116.

117.
118.
119.
120.

public String getApellido() {


return _apellido;
}
public void setApellido(String _apellido) {
this._apellido = _apellido;
}

121.
122.
123.
124.

125.
126.
127.
128.

public String getDomicilio() {


return _domicilio;
}
public void setDomicilio(String _domicilio) {
this._domicilio = _domicilio;
}

129.
130.
131.
132.

133.
134.
135.
136.
137. }

public String getTelefono() {


return _telefono;
}
public void setTelefono(String _telefono) {
this._telefono = _telefono;
}

16. Dentro de bibliotecaws.java digitaremos el siguiente cdigo, qu gestionar la


conexin a la base de datos; el listado de libros, ejemplares, usuarios,
ejemplares prestados, ejemplares por devolver; el ingreso y actualizacin de
libros, ejemplares y usuarios; y por ltimo la gestin de prstamos y
devoluciones de ejemplares. Cabe destacar que las primary key de libro y
socio no se autoincrementan por eso se implement el mtodo para generar
sus claves haciendo una consulta del nmero mayor de las primary key
existentes y antes de su devolucin se incrementa en 1:

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.

package biblioteca.ec;
/*
* @author LuisFernando
*/
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import javax.jws.WebService;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import identidades.ec.lista;
import java.sql.PreparedStatement;
/**
*
* @author LuisFernando
*/
@WebService(serviceName = "bibliotecaws")
public class bibliotecaws {
/**
* Gestor de consultas
*/

27.
28.
29.
30.
31.
32.
33.
34.
35.
36.

@WebMethod(operationName = "Listas")
public List<lista> Listas(@WebParam(name = "parameter") int parameter) {
List<lista> lista = new ArrayList<lista>();
lista l = null;
try {
ResultSet rs;
Class.forName("com.mysql.jdbc.Driver");
Connection conexion;

conexion=DriverManager.getConnection("jdbc:mysql://localhost:3306/bddbibliotec
a","root","soa2014");
37.
Statement st = conexion.createStatement();
38.
39.
switch(parameter){
40.
case 1:
41.
rs = st.executeQuery("select * from libro");
42.
while(rs.next()) {
43.
l = new lista();
44.
l.setId_libro(rs.getInt(1));
45.
l.setTitulo(rs.getString(2));
46.
l.setAutor(rs.getString(3));
47.
l.setTema(rs.getString(4));
48.
l.setAo(rs.getInt(5));
49.
lista.add(l);
50.
}
51.
st.close();
52.
conexion.close();
53.
break;
54.
case 2:
55.
rs = st.executeQuery("select l.id_libro, l.titulo Libro,
TI.Ejemplares, TD.Disponibles from libro l right join (select l.id_libro ID,
count(*) Ejemplares from libro l, ejemplar e where l.id_libro = e.id_libro
group by l.id_libro) TI on TI.ID = l.id_libro left join (select l.id_libro ID,
l.titulo, count(*) Disponibles from libro l, ejemplar e where l.id_libro =
e.id_libro and e.disponible=1 group by l.id_libro) TD on TD.ID = l.id_libro");
56.
while(rs.next()) {
57.
l = new lista();
58.
l.setId_libro(rs.getInt(1));
59.
l.setTitulo(rs.getString(2));
60.
l.setEjemplares(rs.getInt(3));
61.
l.setDisponibles(rs.getInt(4));
62.
lista.add(l);
63.
}
64.
st.close();
65.
conexion.close();
66.
break;
67.
case 3:
68.
rs = st.executeQuery("select p.id_ejemplar, p.id_libro,
p.id_socio, concat(s.nombre,' ', s.apellido) Socio, l.titulo Libro,
s.domicilio Domicilio, s.telefono Telefono, p.fecha Fecha from ejemplar e,
libro l, prestamo p, socio s where p.id_ejemplar = e.id_ejemplar and
p.id_libro = e.id_libro and p.id_socio = s.id_socio and p.id_libro =
l.id_libro and p.estado=1");
69.
while(rs.next()) {
70.
l = new lista();
71.
l.setId_ejemplar(rs.getInt(1));
72.
l.setId_libro(rs.getInt(2));
73.
l.setId_socio(rs.getInt(3));
74.
l.setNombre(rs.getString(4));
75.
l.setTitulo(rs.getString(5));
76.
l.setDomicilio(rs.getString(6));
77.
l.setTelefono(rs.getString(7));
78.
l.setFecha(rs.getString(8));
79.
lista.add(l);
80.
}
81.
st.close();
82.
conexion.close();
83.
break;

84.
85.
86.
87.
88.
89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.

case 4:
rs = st.executeQuery("select * from socio");
while(rs.next()) {
l = new lista();
l.setId_socio(rs.getInt(1));
l.setNombre(rs.getString(2));
l.setApellido(rs.getString(3));
l.setDomicilio(rs.getString(4));
l.setTelefono(rs.getString(5));
lista.add(l);
}
st.close();
conexion.close();
break;
case 5:
rs = st.executeQuery("select l.id_libro, l.titulo Libro,
l.autor, l.tema, l.ao, count(*) Ejemplares from libro l, ejemplar e where
l.id_libro = e.id_libro group by l.id_libro");
100.
while(rs.next()) {
101.
l = new lista();
102.
l.setId_libro(rs.getInt(1));
103.
l.setTitulo(rs.getString(2));
104.
l.setAutor(rs.getString(3));
105.
l.setTema(rs.getString(4));
106.
l.setAo(rs.getInt(5));
107.
l.setEjemplares(rs.getInt(6));
108.
lista.add(l);
109.
}
110.
st.close();
111.
conexion.close();
112.
break;
113.
case 6:
114.
rs = st.executeQuery("select distinct l.id_libro,
e.id_ejemplar, l.titulo, l.autor, l.tema, l.ao from libro l, ejemplar e where
l.id_libro = e.id_libro and e.disponible = 1 order by l.id_libro");
115.
while(rs.next()) {
116.
l = new lista();
117.
l.setId_libro(rs.getInt(1));
118.
l.setId_ejemplar(rs.getInt(2));
119.
l.setTitulo(rs.getString(3));
120.
l.setAutor(rs.getString(4));
121.
l.setTema(rs.getString(5));
122.
l.setAo(rs.getInt(6));
123.
lista.add(l);
124.
}
125.
st.close();
126.
conexion.close();
127.
break;
128.
case 7:
129.
rs = st.executeQuery("select p.id_libro, p.id_ejemplar,
l.titulo, p.id_socio, concat(s.nombre, \" \" ,s.apellido) Nombre from prestamo
p, libro l, socio s, ejemplar e where p.id_libro = l.id_libro and p.id_socio =
s.id_socio and e.id_libro = p.id_libro and e.id_ejemplar = p.id_ejemplar and
e.disponible=0 order by l.id_libro");
130.
while(rs.next()) {
131.
l = new lista();
132.
l.setId_libro(rs.getInt(1));
133.
l.setId_ejemplar(rs.getInt(2));
134.
l.setTitulo(rs.getString(3));
135.
l.setId_socio(rs.getInt(4));
136.
l.setNombre(rs.getString(5));
137.
lista.add(l);
138.
}
139.
st.close();
140.
conexion.close();
141.
break;
142.
default:
143.
break;
144.
}

145.
146.
147.
}
148.
catch (Exception e) {
149.
System.out.println("Error al realizar consulta");
150.
}
151.
return lista;
152.
}
153.
154.
/**
155.
* Generador de cdigos
156.
*/
157.
@WebMethod(operationName = "generadorCodigos")
158.
public int generadorCodigos(@WebParam(name = "parameter") int
parameter) {
159.
int nuevoId=0;
160.
try {
161.
ResultSet rs;
162.
Class.forName("com.mysql.jdbc.Driver");
163.
Connection conexion;
164.
conexion=DriverManager.getConnection("jdbc:mysql://localhost:3306/bddbibliotec
a","root","soa2014");
165.
Statement st = conexion.createStatement();
166.
167.
switch(parameter){
168.
case 1:
169.
rs = st.executeQuery("select max(id_libro) id from
libro");
170.
rs.first();
171.
nuevoId=rs.getInt(1);
172.
st.close();
173.
conexion.close();
174.
break;
175.
case 2:
176.
rs = st.executeQuery("select max(id_socio) id from
socio");
177.
rs.first();
178.
nuevoId=rs.getInt(1);
179.
st.close();
180.
conexion.close();
181.
break;
182.
default:
183.
break;
184.
}
185.
}
186.
catch (Exception e) {
187.
System.out.println("Error al realizar consulta");
188.
}
189.
return nuevoId+1;
190.
}
191.
192.
/**
193.
* Insertar libro
194.
*/
195.
@WebMethod(operationName = "insertarLibro")
196.
public boolean insertarLibro(@WebParam(name = "titulo") String titulo,
@WebParam(name = "autor") String autor, @WebParam(name = "tema") String tema,
@WebParam(name = "a\u00f1o") int ao) {
197.
boolean resp = false;
198.
try {
199.
Class.forName("com.mysql.jdbc.Driver");
200.
Connection conexion;
201.
conexion=DriverManager.getConnection("jdbc:mysql://localhost:3306/bddbibliotec
a","root","soa2014");
202.
203.
PreparedStatement pst = conexion.prepareStatement("insert into
libro values (?,?,?,?,?)");

204.
205.
pst.setInt(1, this.generadorCodigos(1));
206.
pst.setString(2, titulo);
207.
pst.setString(3, autor);
208.
pst.setString(4, tema);
209.
pst.setInt(5, ao);
210.
211.
pst.executeUpdate();
212.
213.
pst.close();
214.
conexion.close();
215.
resp = true;
216.
}
217.
catch (Exception e) {
218.
resp = false;
219.
}
220.
return resp;
221.
}
222.
223.
/**
224.
* Insertar socio
225.
*/
226.
@WebMethod(operationName = "insertarSocio")
227.
public boolean insertarSocio(@WebParam(name = "nombre") String nombre,
@WebParam(name = "apellido") String apellido, @WebParam(name = "domicilio")
String domicilio, @WebParam(name = "telefono") String telefono) {
228.
boolean resp = false;
229.
try {
230.
Class.forName("com.mysql.jdbc.Driver");
231.
Connection conexion;
232.
conexion=DriverManager.getConnection("jdbc:mysql://localhost:3306/bddbibliotec
a","root","soa2014");
233.
234.
PreparedStatement pst = conexion.prepareStatement("insert into
socio values (?,?,?,?,?)");
235.
236.
pst.setInt(1, this.generadorCodigos(2));
237.
pst.setString(2, nombre);
238.
pst.setString(3, apellido);
239.
pst.setString(4, domicilio);
240.
pst.setString(5, telefono);
241.
242.
pst.executeUpdate();
243.
244.
pst.close();
245.
conexion.close();
246.
resp = true;
247.
}
248.
catch (Exception e) {
249.
resp = false;
250.
}
251.
return resp;
252.
}
253.
254.
/**
255.
* Insertar Ejemplar
256.
*/
257.
@WebMethod(operationName = "insertarEjemplar")
258.
public boolean insertarEjemplar(@WebParam(name = "idLibro") int
idLibro) {
259.
boolean resp = false;
260.
try {
261.
Class.forName("com.mysql.jdbc.Driver");
262.
Connection conexion;
263.
conexion=DriverManager.getConnection("jdbc:mysql://localhost:3306/bddbibliotec
a","root","soa2014");
264.

265.
PreparedStatement pst = conexion.prepareStatement("insert into
ejemplar(id_libro, disponible) values (?, '1')");
266.
267.
pst.setInt(1, idLibro);
268.
pst.executeUpdate();
269.
270.
pst.close();
271.
conexion.close();
272.
resp = true;
273.
}
274.
catch (Exception e) {
275.
resp = false;
276.
}
277.
return resp;
278.
}
279.
280.
/**
281.
* Gestin de Prstamos y Devoluciones
282.
*/
283.
@WebMethod(operationName = "prestamoDevolucion")
284.
public boolean prestamoDevolucion(@WebParam(name = "fecha") String
fecha, @WebParam(name = "id_ejemplar") int id_ejemplar, @WebParam(name =
"id_libro") int id_libro, @WebParam(name = "id_socio") int id_socio,
@WebParam(name = "estado") String estado) {
285.
//String mensaje="Error al registar solicitud de prstamo";
286.
boolean resp = false;
287.
try {
288.
Class.forName("com.mysql.jdbc.Driver");
289.
Connection conexion;
290.
conexion=DriverManager.getConnection("jdbc:mysql://localhost:3306/bddbibliotec
a","root","soa2014");
291.
292.
PreparedStatement pst = conexion.prepareStatement("insert into
prestamo(fecha, id_ejemplar, id_libro, id_socio, estado) values
('"+fecha+"', ?, ?, ?, '"+estado+"')");
293.
294.
pst.setInt(1, id_ejemplar);
295.
pst.setInt(2, id_libro);
296.
pst.setInt(3, id_socio);
297.
pst.executeUpdate();
298.
299.
pst.close();
300.
conexion.close();
301.
//mensaje="Prstamo registrado exitosamente";
302.
resp = true;
303.
}
304.
catch (Exception e) {
305.
resp = false;
306.
}
307.
return resp;
308.
}
309.
310.
/**
311.
* Actualizar Ejemplar
312.
*/
313.
@WebMethod(operationName = "actualizarEjemplar")
314.
public boolean actualizarEjemplar(@WebParam(name = "disponible") String
disponible, @WebParam(name = "id_ejemplar") String id_ejemplar, @WebParam(name
= "id_libro") String id_libro) {
315.
boolean resp = false;
316.
try {
317.
Class.forName("com.mysql.jdbc.Driver");
318.
Connection conexion;
319.
conexion=DriverManager.getConnection("jdbc:mysql://localhost:3306/bddbibliotec
a","root","soa2014");
320.

321.
PreparedStatement pst = conexion.prepareStatement("update
ejemplar set disponible = '"+disponible+"' where id_ejemplar =
'"+id_ejemplar+"' and id_libro = '"+id_libro+"'");
322.
323.
pst.executeUpdate();
324.
325.
pst.close();
326.
conexion.close();
327.
resp = true;
328.
}
329.
catch (Exception e) {
330.
resp = false;
331.
}
332.
return resp;
333.
}
334.
335.
/**
336.
* Actualizar Libro
337.
*/
338.
@WebMethod(operationName = "actualizarLibro")
339.
public boolean actualizarLibro(@WebParam(name = "id_libro") int
id_libro, @WebParam(name = "titulo") String titulo, @WebParam(name = "autor")
String autor, @WebParam(name = "tema") String tema, @WebParam(name =
"a\u00f1o") String ao) {
340.
boolean resp = false;
341.
try {
342.
Class.forName("com.mysql.jdbc.Driver");
343.
Connection conexion;
344.
conexion=DriverManager.getConnection("jdbc:mysql://localhost:3306/bddbibliotec
a","root","soa2014");
345.
346.
PreparedStatement pst = conexion.prepareStatement("update libro
set titulo = '"+titulo+"', autor = '"+autor+"', tema = '"+tema+"', ao =
'"+ao+"' where id_libro = '"+id_libro+"'");
347.
pst.executeUpdate();
348.
349.
350.
pst.close();
351.
conexion.close();
352.
//mensaje="Insercin del libro exitosa";
353.
resp = true;
354.
}
355.
catch (Exception e) {
356.
resp = false;
357.
}
358.
return resp;
359.
}
360.
361.
/**
362.
* Actualizar Usuario
363.
*/
364.
@WebMethod(operationName = "actualizarUsuario")
365.
public boolean actualizarUsuario(@WebParam(name = "id_usuario") int
id_usuario, @WebParam(name = "nombre") String nombre, @WebParam(name =
"apellido") String apellido, @WebParam(name = "domicilio") String domicilio,
@WebParam(name = "telefono") String telefono) {
366.
boolean resp = false;
367.
try {
368.
Class.forName("com.mysql.jdbc.Driver");
369.
Connection conexion;
370.
conexion=DriverManager.getConnection("jdbc:mysql://localhost:3306/bddbibliotec
a","root","soa2014");
371.
372.
PreparedStatement pst = conexion.prepareStatement("update socio
set nombre = '"+nombre+"', apellido = '"+apellido+"', domicilio =
'"+domicilio+"', telefono = '"+telefono+"' where id_socio =
'"+id_usuario+"'");

373.
374.
375.
376.
377.
378.
379.
380.
381.
382.
383.
384.
385.

pst.executeUpdate();
pst.close();
conexion.close();
resp = true;
}
catch (Exception e) {
resp = false;
}
return resp;
}
}

17. Por ltimo damos clic derecho sobre ZServer y seleccionamos Deploy para
desplegar el servicio web. A continuacin se muestra una captura del
servicio web luego de hacer clic derecho a ZServer/WebServices/bibliotecaws
y seleccionar Test Web Service:

Creacin Ejecucin del Cliente JSF


Para la creacin del servicio web procedemos de la siguiente forma:
1.
2.
3.
4.
5.
6.
7.
8.
9.

Ingresamos al IDE de NetBeans 7.4


Clic en Archivo
Clic en Proyecto Nuevo
Escogemos en Categoras: Java Web
Seleccionamos en Proyectos: Web Applicaton
Clic en Siguiente>
Digitamos .BibliotecaClient en Project Name
Clic en Siguiente
Verificamos que:
a. El servidor sea GlassFish Server 4.0
b. La versin de Java EE sea Java EE 7 Web
10. Clic en Siguiente
11. Seleccionamos la casilla JavaServer Faces y verificamos que est seleccionada
la opcin Server Library: JSF 2.2
12. En la misma ventana seleccionamos la pestaa Componentes seleccionamos
la casilla PrimeFaces (en caso de no tener esa biblioteca la podemos
conseguir en http://www.primefaces.org/ posterior al registro gratuito)
13. Clic en Terminar
14. Creado el proyecto hacemos clic derecho sobre .BibliotecaClient y
seleccionamos Nuevo/JSF Managed Bean
15. En Nombre de Clase digitamos JSFManageBeanBiblioteca y en Paquete
digitamos: biblioteca.ec
16. Luego
hacemos
clic
derecho
sobre
.BibliotecaClient/WebPages
y
seleccionamos Nuevo/XHTML
17. En XHTML File Name digitamos: Libros_Todos y damos clic en Terminar
18. Repetimos los paso 16 y 17 para agregar: Libro_Nuevo, Ejemplares_Todos,
Ejemplar_Nuevo,
Ejemplar_Prestamo,
Ejemplar_Devolucion,
Ejemplar_Reporte, Usuarios_Todos y Usuario_Nuevo
19. Hacemos clic derecho sobre .BibliotecaClient y seleccionamos Nuevo/Web
Service Client
20. En la ventana que aparece hacemos clic en Browse
21. En el cuadro que aparece ubicamos ZServer/bibliotecaws y damos clic en
Aceptar, por ltimo de vuelta a la primera ventana damos clic en Terminar
En ste punto el cliente JSF se mostrar de la siguiente forma (en la carpeta
temas est un archivo css, y una carpeta de imgenes que se utilizarn en el
proyecto):

22. Dentro de JSFManagedBeanBiblioteca.java digitaremos el siguiente cdigo


(para generar automticamente las finciones GET y SET: damos clic derecho
sobre los atributos seleccionados y seleccionamos Inserta cdigo y luego
seleccionamos Getter y Setter; para llamar a las operaciones del servicio web
agregado como referencia: damos clic derecho sobre el editor de cdigo y
seleccionamos Inserta cdigo y luego seleccionamos Call Web Service
Operation, en el cuadro que aparece seleccionamos dentro de
.BibliotecaClient/bibliotecaws/bibliotecaws/bibliotecawsPort las operaciones
antes programadas y que necesitemos)

1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.

package biblioteca.ec;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.xml.ws.WebServiceRef;
import org.primefaces.component.datatable.DataTable;
import biblioteca.ec.Lista;
import java.util.ArrayList;
import java.util.List;
/*
* @author LuisFernando
*/
@ManagedBean
@RequestScoped
public class JSFManagedBeanBiblioteca {
@WebServiceRef(wsdlLocation = "WEBINF/wsdl/localhost_8080/ZServer/bibliotecaws.wsdl")

18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.

private Bibliotecaws_Service service;


public DataTable getTabla() {
return tabla;
}
public void setTabla(DataTable tabla) {
this.tabla = tabla;
}
DataTable tabla;
Lista lista;
public Lista getLibro() {
return lista;
}
public void setLibro(Lista lista) {
this.lista = lista;
}
String Mensaje="";
int _id_libro;
String _titulo;
String _autor;
String _tema;
int _ao;
public String getFecha() {
return _fecha;
}
public void setFecha(String _fecha) {
this._fecha = _fecha;
}
String _fecha;
public int getId_ejemplar() {
return _id_ejemplar;
}
public void setId_ejemplar(int _id_ejemplar) {
this._id_ejemplar = _id_ejemplar;
}
int _id_ejemplar;
public String getNombre() {
return _nombre;
}
public void setNombre(String _nombre) {
this._nombre = _nombre;
}
public String getApellido() {
return _apellido;
}
public void setApellido(String _apellido) {
this._apellido = _apellido;
}
public String getDomicilio() {
return _domicilio;
}
public void setDomicilio(String _domicilio) {

89.
90.
91.
92.
93.
94.
95.
96.
97.
98.
99.
100.
101.
102.
103.
104.
105.
106.
107.
108.
109.
110.
111.
112.
113.
114.
115.
116.
117.
118.
119.
120.
121.
122.
123.
124.
125.
126.
127.
128.
129.
130.
131.
132.
133.
134.
135.
136.
137.
138.
139.
140.
141.
142.
143.
144.
145.
146.
147.
148.
149.
150.
151.
152.
153.
154.
155.
156.
157.
158.
159.

this._domicilio = _domicilio;
}
public String getTelefono() {
return _telefono;
}
public void setTelefono(String _telefono) {
this._telefono = _telefono;
}
public int getId_usuario() {
return _id_usuario;
}
public void setId_usuario(int _id_usuario) {
this._id_usuario = _id_usuario;
}
int _id_usuario;
String _nombre;
String _apellido;
String _domicilio;
String _telefono;
public String getMensaje() {
return Mensaje;
}
public void setMensaje(String Mensaje) {
this.Mensaje = Mensaje;
}

public Bibliotecaws_Service getService() {


return service;
}
public void setService(Bibliotecaws_Service service) {
this.service = service;
}
public int getId_libro() {
return _id_libro;
}
public void setId_libro(int _id_libro) {
this._id_libro = _id_libro;
}
public String getTitulo() {
return _titulo;
}
public void setTitulo(String _titulo) {
this._titulo = _titulo;
}
public String getAutor() {
return _autor;
}
public void setAutor(String _autor) {
this._autor = _autor;
}
public String getTema() {
return _tema;
}

160.
public void setTema(String _tema) {
161.
this._tema = _tema;
162.
}
163.
164.
public int getAo() {
165.
return _ao;
166.
}
167.
168.
public void setAo(int _ao) {
169.
this._ao = _ao;
170.
}
171.
172.
/**
173.
* Creates a new instance of JSFManagedBeanBiblioteca
174.
*/
175.
public JSFManagedBeanBiblioteca() {
176.
}
177.
178.
public java.util.List<biblioteca.ec.Lista> libros() {
179.
return listas(1);
180.
}
181.
182.
public java.util.List<biblioteca.ec.Lista> reporteEjemplares() {
183.
return listas(2);
184.
}
185.
186.
public java.util.List<biblioteca.ec.Lista> usuarios() {
187.
return listas(4);
188.
}
189.
190.
public java.util.List<biblioteca.ec.Lista> ejemplares() {
191.
return listas(5);
192.
}
193.
194.
public java.util.List<biblioteca.ec.Lista> ejemplaresDisponibles() {
195.
return listas(6);
196.
}
197.
198.
public java.util.List<biblioteca.ec.Lista> ejemplaresDevolucion() {
199.
return listas(7);
200.
}
201.
202.
public void nuevoLibro() {
203.
boolean sql = insertarLibro(_titulo, _autor, _tema, _ao);
204.
if (sql==true){
205.
Mensaje="Libro registrado con xito";
206.
}else{
207.
Mensaje="No se pudo registrar el libro, por favor revise los
datos ingresados";
208.
}
209.
}
210.
211.
public void actualizarLibro() {
212.
213.
boolean sql = actualizarLibro(this._id_libro,this._titulo,
this._autor, this._tema, Integer.toString(this._ao));
214.
if (_id_libro==0){
215.
Mensaje="No se pudo actualizar el libro, por favor revise los
datos ingresados";
216.
}
217.
else {
218.
if (sql==true){
219.
Mensaje="Libro actualizado con xito";
220.
}else{
221.
Mensaje="No se pudo actualizar el libro, por favor revise
los datos ingresados";
222.
}
223.
}
224.
}
225.
226.
public void actualizarUsuario(){

227.
boolean sql = actualizarUsuario(this._id_usuario, this._nombre,
this._apellido, this._domicilio, this._telefono);
228.
if (_id_usuario==0){
229.
Mensaje="No se pudo actualizar el usuario, por favor revise los
datos ingresados";
230.
}
231.
else {
232.
if (sql==true){
233.
Mensaje="Usuario actualizado con xito";
234.
}else{
235.
Mensaje="No se pudo actualizar el usuario, por favor revise
los datos ingresados";
236.
}
237.
}
238.
}
239.
240.
public void nuevoUsuario() {
241.
boolean sql = insertarSocio(this._nombre, this._apellido,
this._domicilio, this._telefono);
242.
if (sql==true){
243.
Mensaje="Usuario Registrado con xito";
244.
}else{
245.
Mensaje="No se pudo registrar el nuevo socio, por favor revise
los datos ingresados";
246.
}
247.
}
248.
249.
public void reset(){
250.
this._id_libro=0;
251.
this._titulo=null;
252.
this._autor=null;
253.
this._tema=null;
254.
this._ao= 0;
255.
256.
this._nombre=null;
257.
this._apellido=null;
258.
this._domicilio=null;
259.
this._telefono=null;
260.
}
261.
262.
public void nuevoEjemplar()
263.
{
264.
boolean sql = insertarEjemplar(this._id_libro);
265.
if (sql==true){
266.
Mensaje="Ejemplar registrado con xito";
267.
}else{
268.
Mensaje="No se pudo registrar el nuevo ejemplar, por favor
revise los datos ingresados";
269.
}
270.
}
271.
272.
public void seleccionLibro(){
273.
lista=(Lista) tabla.getRowData();
274.
this._id_libro=lista.getIdLibro();
275.
this._titulo=lista.getTitulo();
276.
this._autor=lista.getAutor();
277.
this._tema=lista.getTema();
278.
this._ao=lista.getAo();
279.
280.
}
281.
282.
public void seleccionUsuario(){
283.
lista=(Lista) tabla.getRowData();
284.
this._id_usuario=lista.getIdSocio();
285.
this._nombre=lista.getNombre();
286.
this._apellido=lista.getApellido();
287.
this._domicilio=lista.getDomicilio();
288.
this._telefono=lista.getTelefono();
289.
290.
}
291.

292.
public void seleccionEjemplar(){
293.
lista=(Lista) tabla.getRowData();
294.
this._id_libro=lista.getIdLibro();
295.
this._id_ejemplar=lista.getIdEjemplar();
296.
this._titulo=lista.getTitulo();
297.
this._autor=lista.getAutor();
298.
this._tema=lista.getTema();
299.
this._ao=lista.getAo();
300.
301.
}
302.
303.
public void seleccionDevolucion(){
304.
lista=(Lista) tabla.getRowData();
305.
this._id_libro=lista.getIdLibro();
306.
this._id_ejemplar=lista.getIdEjemplar();
307.
this._titulo=lista.getTitulo();
308.
this._id_usuario=lista.getIdSocio();
309.
this._nombre=lista.getNombre();
310.
311.
}
312.
313.
public void prestamo(){
314.
boolean sqlp = prestamoDevolucion(_fecha, _id_ejemplar, _id_libro,
_id_usuario, "1");
315.
if (sqlp==true) {
316.
boolean sqla = actualizarEjemplar("0",
Integer.toString(_id_ejemplar), Integer.toString(_id_libro));
317.
if (sqla==true) {
318.
Mensaje="Prstamo registrado con xito";
319.
}
320.
}
321.
else {
322.
Mensaje="Prstamo no registrado, recuerde que la fecha debe
estar en el formato: aaaa-mm-dd";
323.
}
324.
}
325.
326.
public void devolucion(){
327.
boolean sqlp = prestamoDevolucion(_fecha, _id_ejemplar, _id_libro,
_id_usuario, "0");
328.
if (sqlp==true) {
329.
boolean sqla = actualizarEjemplar("1",
Integer.toString(_id_ejemplar), Integer.toString(_id_libro));
330.
if (sqla==true) {
331.
Mensaje="Devolucin registrada con xito";
332.
}
333.
}
334.
else {
335.
Mensaje="Devolucin no registrada, recuerde que la fecha debe
estar en el formato: aaaa-mm-dd";
336.
}
337.
338.
339.
340.
}
341.
342.
343.
344.
345.
private java.util.List<biblioteca.ec.Lista> listas(int parameter) {
346.
// Note that the injected javax.xml.ws.Service reference as well as
port objects are not thread safe.
347.
// If the calling of port operations may lead to race condition
some synchronization is required.
348.
biblioteca.ec.Bibliotecaws port = service.getBibliotecawsPort();
349.
return port.listas(parameter);
350.
}
351.
352.
private boolean insertarLibro(java.lang.String titulo, java.lang.String
autor, java.lang.String tema, int ao) {

353.
// Note that the injected javax.xml.ws.Service reference as well as
port objects are not thread safe.
354.
// If the calling of port operations may lead to race condition
some synchronization is required.
355.
biblioteca.ec.Bibliotecaws port = service.getBibliotecawsPort();
356.
return port.insertarLibro(titulo, autor, tema, ao);
357.
}
358.
359.
private boolean actualizarLibro(int idLibro, java.lang.String titulo,
java.lang.String autor, java.lang.String tema, java.lang.String ao) {
360.
// Note that the injected javax.xml.ws.Service reference as well as
port objects are not thread safe.
361.
// If the calling of port operations may lead to race condition
some synchronization is required.
362.
biblioteca.ec.Bibliotecaws port = service.getBibliotecawsPort();
363.
return port.actualizarLibro(idLibro, titulo, autor, tema, ao);
364.
}
365.
366.
private boolean insertarSocio(java.lang.String nombre, java.lang.String
apellido, java.lang.String domicilio, java.lang.String telefono) {
367.
// Note that the injected javax.xml.ws.Service reference as well as
port objects are not thread safe.
368.
// If the calling of port operations may lead to race condition
some synchronization is required.
369.
biblioteca.ec.Bibliotecaws port = service.getBibliotecawsPort();
370.
return port.insertarSocio(nombre, apellido, domicilio, telefono);
371.
}
372.
373.
private boolean insertarEjemplar(int idLibro) {
374.
// Note that the injected javax.xml.ws.Service reference as well as
port objects are not thread safe.
375.
// If the calling of port operations may lead to race condition
some synchronization is required.
376.
biblioteca.ec.Bibliotecaws port = service.getBibliotecawsPort();
377.
return port.insertarEjemplar(idLibro);
378.
}
379.
380.
private boolean actualizarUsuario(int idUsuario, java.lang.String
nombre, java.lang.String apellido, java.lang.String domicilio,
java.lang.String telefono) {
381.
// Note that the injected javax.xml.ws.Service reference as well as
port objects are not thread safe.
382.
// If the calling of port operations may lead to race condition
some synchronization is required.
383.
biblioteca.ec.Bibliotecaws port = service.getBibliotecawsPort();
384.
return port.actualizarUsuario(idUsuario, nombre, apellido,
domicilio, telefono);
385.
}
386.
387.
private boolean prestamoDevolucion(java.lang.String fecha, int
idEjemplar, int idLibro, int idSocio, java.lang.String estado) {
388.
// Note that the injected javax.xml.ws.Service reference as well as
port objects are not thread safe.
389.
// If the calling of port operations may lead to race condition
some synchronization is required.
390.
biblioteca.ec.Bibliotecaws port = service.getBibliotecawsPort();
391.
return port.prestamoDevolucion(fecha, idEjemplar, idLibro, idSocio,
estado);
392.
}
393.
394.
private boolean actualizarEjemplar(java.lang.String disponible,
java.lang.String idEjemplar, java.lang.String idLibro) {
395.
// Note that the injected javax.xml.ws.Service reference as well as
port objects are not thread safe.
396.
// If the calling of port operations may lead to race condition
some synchronization is required.
397.
biblioteca.ec.Bibliotecaws port = service.getBibliotecawsPort();
398.
return port.actualizarEjemplar(disponible, idEjemplar, idLibro);
399.
}
400.
}

23. En el archivo index.xhtm se digitar:


1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.

<?xml version='1.0' encoding='UTF-8' ?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
<title>Biblioteca</title>
<link rel="stylesheet" type="text/css" href="temas/zxc.css" />
</h:head>
<h:body>
<div id="top">
<ui:insert name="top">
GESTIN DE BIBLIOTECA
</ui:insert>
</div>
<div style="font-size: 22px;">
<h:form>
<p:menubar>
<p:submenu label="Inicio">
<p:menuitem
url="http://localhost:8080/.BibliotecaClient/faces/index.xhtml" value="Inicio"
icon="ui-icon-document" />
</p:submenu>
<p:submenu label="Libros">
<p:menuitem
url="http://localhost:8080/.BibliotecaClient/faces/Libros_Todos.xhtml"
value="Libros" icon="ui-icon-document" />
<p:menuitem
url="http://localhost:8080/.BibliotecaClient/faces/Libro_Nuevo.xhtml"
value="Nuevo" icon="ui-icon-document" />
</p:submenu>
<p:submenu label="Ejemplares">
<p:menuitem
url="http://localhost:8080/.BibliotecaClient/faces/Ejemplares_Todos.xhtml"
value="Ejemplares" icon="ui-icon-arrowthick-1-s" />
<p:menuitem
url="http://localhost:8080/.BibliotecaClient/faces/Ejemplar_Prestamo.xhtml"
value="Prstamos" icon="ui-icon-arrowthick-1-s" />
<p:menuitem
url="http://localhost:8080/.BibliotecaClient/faces/Ejemplar_Devolucion.xhtml"
value="Devoluciones" icon="ui-icon-arrowthick-1-s" />
<p:menuitem
url="http://localhost:8080/.BibliotecaClient/faces/Ejemplar_Nuevo.xhtml"
value="Nuevo" icon="ui-icon-arrowthick-1-s" />
<p:menuitem
url="http://localhost:8080/.BibliotecaClient/faces/Ejemplar_Reporte.xhtml"
value="Reporte" icon="ui-icon-arrowthick-1-s" />
</p:submenu>
<p:submenu label="Usuarios">
<p:menuitem
url="http://localhost:8080/.BibliotecaClient/faces/Usuarios_Todos.xhtml"
value="Usuarios" icon="ui-icon-wrench" />
<p:menuitem
url="http://localhost:8080/.BibliotecaClient/faces/Usuario_Nuevo.xhtml"
value="Nuevo" icon="ui-icon-wrench" />
</p:submenu>
</p:menubar>
</h:form>

46.
47.
48.
49.
50.
51.
52.
53.
54.

</div>

55.
56.
57.

<div id="center">
<div id="left">
<ui:insert name="menu">
<h:form>
<p:panelMenu>
<p:submenu label="Inicio">
<p:menuitem
url="http://localhost:8080/.BibliotecaClient/faces/index.xhtml" value="Inicio"
icon="ui-icon-document" />
</p:submenu>
<p:submenu label="Libros" icon="ui-icon-heart">
<p:menuitem
url="http://localhost:8080/.BibliotecaClient/faces/Libros_Todos.xhtml"
value="Libros" icon="ui-icon-document" />
<p:menuitem
url="http://localhost:8080/.BibliotecaClient/faces/Libro_Nuevo.xhtml"
value="Nuevo" icon="ui-icon-document" />
</p:submenu>
<p:submenu label="Ejemplares" icon="ui-iconheart">
<p:menuitem
url="http://localhost:8080/.BibliotecaClient/faces/Ejemplares_Todos.xhtml"
value="Ejemplares" icon="ui-icon-arrowthick-1-s" />
<p:menuitem
url="http://localhost:8080/.BibliotecaClient/faces/Ejemplar_Nuevo.xhtml"
value="Nuevo" icon="ui-icon-arrowthick-1-s" />
<p:menuitem
url="http://localhost:8080/.BibliotecaClient/faces/Ejemplar_Prestamo.xhtml"
value="Prstamos" icon="ui-icon-arrowthick-1-s" />
<p:menuitem
url="http://localhost:8080/.BibliotecaClient/faces/Ejemplar_Devolucion.xhtml"
value="Devoluciones" icon="ui-icon-arrowthick-1-s" />
<p:menuitem
url="http://localhost:8080/.BibliotecaClient/faces/Ejemplar_Reporte.xhtml"
value="Reporte" icon="ui-icon-arrowthick-1-s" />
</p:submenu>
<p:submenu label="Usuarios" icon="ui-icon-heart">
<p:menuitem
url="http://localhost:8080/.BibliotecaClient/faces/Usuarios_Todos.xhtml"
value="Usuarios" icon="ui-icon-wrench" />
<p:menuitem
url="http://localhost:8080/.BibliotecaClient/faces/Usuario_Nuevo.xhtml"
value="Nuevo" icon="ui-icon-wrench" />
</p:submenu>
</p:panelMenu>
</h:form>
</ui:insert>
</div>

58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.

75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.
86.
87.
88.
89.
90.
91.
92.

<div id="right">
<ui:insert name="contenido">
<div style="text-align: center">
Para iniciar primero elija un elemento del men
<br/><br/>
<h:graphicImage value="/temas/images/biblio.jpg"/>
</div>
</ui:insert>
</div>
</div>
<div id="bottom" >
<ui:insert name="bottom"> Anlisis de Sistemas Informticos Arquitectura Orientada a Servicios </ui:insert>
<br/>
<ui:insert name="bottom"> Luis Ordez / Brbara Barragn EPN2014A </ui:insert>
</div>
</h:body>
</html>

24. En el archivo Libros_Todos.xhtml digitaremos:


1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.

<?xml version='1.0' encoding='UTF-8' ?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<h:head>
<title>Libros</title>
</h:head>
<h:body>
<ui:composition template="./index.xhtml">
<ui:define name="contenido">
<h:form>
<h:panelGrid columns="2" cellpadding="5">
<p:outputLabel style="font-size: 1.2em;" value="Id: "
/>
<p:inputText
value="#{jSFManagedBeanBiblioteca.id_libro}"/>

19.
20.

<p:outputLabel style="font-size: 1.2em;"


value="Ttulo: " />

21.

<p:inputText
value="#{jSFManagedBeanBiblioteca.titulo}"/>

22.
23.

<p:outputLabel style="font-size: 1.2em;" value="Autor:


" />

24.

<p:inputText
value="#{jSFManagedBeanBiblioteca.autor}"/>

25.
26.

<p:outputLabel style="font-size: 1.2em;"


value="Gnero: " />

27.

<p:inputText
value="#{jSFManagedBeanBiblioteca.tema}"/>

28.
29.

<p:outputLabel style="font-size: 1.2em;" value="Ao: "


/>

30.
31.
32.

<p:inputText
value="#{jSFManagedBeanBiblioteca.ao}"/>

<h:commandButton style="width: 100px; height: 30px;


font-size: 0.8em" styleClass="ui-button ui-widget ui-state-default ui-cornerall ui-button-text-only" value="Actualizar" type="submit"
action="#{jSFManagedBeanBiblioteca.actualizarLibro()}"/>
33.
<h:commandButton style="width: 100px; height: 30px;
font-size: 0.8em" styleClass="ui-button ui-widget ui-state-default ui-cornerall ui-button-text-only" value="Cancelar" type="submit"
action="#{jSFManagedBeanBiblioteca.reset()}"/>
34.
</h:panelGrid>
35.
36.
<p colspan="2" align="center" >
37.
<p:outputLabel style="color: red; font-size: 1em;
font-style: italic;" value="#{jSFManagedBeanBiblioteca.mensaje}"/>
38.
</p>
39.
40.
<p:dataTable
41.
paginatorTemplate="{CurrentPageReport}
{FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}
{RowsPerPageDropdown}"
42.
rows="10" paginator="true"
43.
paginatorPosition="top"
44.
var="libro"
value="#{jSFManagedBeanBiblioteca.libros()}"
45.
binding="#{jSFManagedBeanBiblioteca.tabla}">

46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.

<f:facet name="header">
Todos los Libros
</f:facet>
<p:column headerText="Id" style="width: 5%;">
<h:outputText value="#{libro.idLibro}" />
</p:column>
<p:column headerText="Ttulo" style="width: 40%;">
<h:outputText value="#{libro.titulo}" />
</p:column>
<p:column headerText="Autor" style="width: 25%;">
<h:outputText value="#{libro.autor}" />
</p:column>
<p:column headerText="Gnero" style="width: 15%;">
<h:outputText value="#{libro.tema}" />
</p:column>
<p:column headerText="Ao" style="width: 5%;">
<h:outputText value="#{libro.ao}"/>
</p:column>

<p:column style="width: 10%;">


<h:commandLink
action="#{jSFManagedBeanBiblioteca.seleccionLibro()}">
73.
Selecionar
74.
</h:commandLink>
75.
</p:column>
76.
77.
<f:facet name="footer">
78.
Hay
#{fn:length(jSFManagedBeanBiblioteca.libros())} libros registrados.
79.
</f:facet>
80.
</p:dataTable>
81.
</h:form>
82.
</ui:define>
83.
</ui:composition>
84.
</h:body>
85. </html>

25. En el archivo Libro_Nuevo.xhtml digitaremos:


1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.

<?xml version='1.0' encoding='UTF-8' ?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<h:head>
<title>TODO supply a title</title>
</h:head>
<h:body>
<ui:composition template="./index.xhtml">

14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.

<ui:define name="contenido">
<h:form >
<h:panelGrid columns="2" cellpadding="5">
<p:outputLabel style="font-size:
1.2em;" value="Ttulo: " />
<p:inputMask mask="" required="true"
value="#{jSFManagedBeanBiblioteca.titulo}"/>
<p:outputLabel style="font-size:
1.2em;" value="Autor: " />
<p:inputMask mask="" required="true"
value="#{jSFManagedBeanBiblioteca.autor}"/>
<p:outputLabel style="font-size:
1.2em;" value="Gnero: " />
<p:inputMask mask="" required="true"
value="#{jSFManagedBeanBiblioteca.tema}"/>

26.
27.

<p:outputLabel style="font-size:
1.2em;" value="Ao: " />

28.
29.
30.

31.

32.
33.
34.
35.

36.
37.
38.

<p:inputMask mask="9999"
required="true" value="#{jSFManagedBeanBiblioteca.ao}"/>
<h:commandButton style="width: 100px;
height: 30px; font-size: 0.8em" styleClass="ui-button ui-widget
ui-state-default ui-corner-all ui-button-text-only"
value="Insertar" type="submit"
action="#{jSFManagedBeanBiblioteca.nuevoLibro()}"/>
<h:commandButton style="width: 100px;
height: 30px; font-size: 0.8em" styleClass="ui-button ui-widget
ui-state-default ui-corner-all ui-button-text-only"
value="Cancelar" type="reset"
action="#{jSFManagedBeanBiblioteca.reset()}"/>
</h:panelGrid>
<p colspan="2" align="center" >
<p:outputLabel style="color: red; fontsize: 1em; font-style: italic;"
value="#{jSFManagedBeanBiblioteca.mensaje}"/>
</p>
<p:messages id="messages" showDetail="true"
autoUpdate="true" closable="true" />

39.
40.
41.
42.
43.

<p:dataTable

fallida"
44.
45.
46.
47.
48.
49.

scrollable="true"
scrollHeight="240"
emptyMessage="Bsqueda

var="libro"
value="#{jSFManagedBeanBiblioteca.libros()}">
<f:facet name="header">
Libros
</f:facet>

50.

51.
52.
53.
54.

55.
56.
57.
58.

59.
60.
61.
62.

63.
64.
65.
66.

67.
68.
69.
70.
71.

72.
73.
74.
75.
76.
77.
78.

79.

<p:column headerText="Id"
filterBy="#{libro.idLibro}" filterMatchMode="contains"
filterStyle="width: 75%;" style="width: 5%;">
<h:outputText
value="#{libro.idLibro}" />
</p:column>
<p:column headerText="Ttulo"
filterBy="#{libro.titulo}" filterMatchMode="contains"
filterStyle="width: 75%;" style="width: 50%;">
<h:outputText
value="#{libro.titulo}" />
</p:column>
<p:column headerText="Autor"
filterBy="#{libro.autor}" filterMatchMode="contains"
filterStyle="width: 75%;" style="width: 25%;">
<h:outputText
value="#{libro.autor}" />
</p:column>
<p:column headerText="Gnero"
filterBy="#{libro.tema}" filterMatchMode="contains"
filterStyle="width: 75%;" style="width: 15%;">
<h:outputText value="#{libro.tema}"
/>
</p:column>
<p:column headerText="Ao"
filterBy="#{libro.ao}" filterMatchMode="contains"
filterStyle="width: 75%;" style="width: 5%;">
<h:outputText
value="#{libro.ao}"/>
</p:column>
<f:facet name="footer">
Hay
#{fn:length(jSFManagedBeanBiblioteca.libros())} libros
registrados.
</f:facet>
</p:dataTable>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>

80.

26. En el archivo Ejemplares_Todos.xhtml digitaremos:


1. <?xml version='1.0' encoding='UTF-8' ?>
2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3. <html xmlns="http://www.w3.org/1999/xhtml"
4.
xmlns:h="http://xmlns.jcp.org/jsf/html"
5.
xmlns:f="http://java.sun.com/jsf/core"
6.
xmlns:p="http://primefaces.org/ui"
7.
xmlns:ui="http://java.sun.com/jsf/facelets"

8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.

xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<h:head>
<title>TODO supply a title</title>
</h:head>
<h:body>
<ui:composition template="./index.xhtml">
<ui:define name="contenido">
<h:form>
<p:dataTable
scrollable="true"
scrollHeight="500"
emptyMessage="Bsqueda
fallida"
var="libro"
value="#{jSFManagedBeanBiblioteca.ejemplares()}">

22.
23.
24.
25.
26.

27.
28.
29.
30.

31.
32.
33.
34.

35.
36.
37.
38.

39.
40.
41.
42.

43.
44.
45.
46.

<f:facet name="header">
Todos los Ejemplares
</f:facet>
<p:column headerText="Id"
filterBy="#{libro.idLibro}" filterMatchMode="contains"
filterStyle="width: 75%;" style="width: 5%;">
<h:outputText
value="#{libro.idLibro}" />
</p:column>
<p:column headerText="Ttulo"
filterBy="#{libro.titulo}" filterMatchMode="contains"
filterStyle="width: 75%;" style="width: 40%;">
<h:outputText
value="#{libro.titulo}" />
</p:column>
<p:column headerText="Autor"
filterBy="#{libro.autor}" filterMatchMode="contains"
filterStyle="width: 75%;" style="width: 30%;">
<h:outputText
value="#{libro.autor}" />
</p:column>
<p:column headerText="Gnero"
filterBy="#{libro.tema}" filterMatchMode="contains"
filterStyle="width: 75%;" style="width: 15%;">
<h:outputText value="#{libro.tema}"
/>
</p:column>
<p:column headerText="Ao"
filterBy="#{libro.ao}" filterMatchMode="contains"
filterStyle="width: 75%;" style="width: 5%;">
<h:outputText value="#{libro.ao}"
/>
</p:column>
<p:column headerText="# Ejem."
style="width: 5%;">

47.
48.
49.
50.
51.

52.
53.
54.
55.
56.
57.

58.

<h:outputText
value="#{libro.ejemplares}" />
</p:column>
<f:facet name="footer">
Hay
#{fn:length(jSFManagedBeanBiblioteca.libros())} libros
registrados.
</f:facet>
</p:dataTable>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>

27. En el archivo Ejemplar_Nuevo.xhtml digitaremos:


1. <?xml version='1.0' encoding='UTF-8' ?>
2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3. <html xmlns="http://www.w3.org/1999/xhtml"
4.
xmlns:h="http://xmlns.jcp.org/jsf/html"
5.
xmlns:f="http://java.sun.com/jsf/core"
6.
xmlns:p="http://primefaces.org/ui"
7.
xmlns:ui="http://java.sun.com/jsf/facelets"
8.
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
9.
<h:head>
10.
<title>TODO supply a title</title>
11.
</h:head>
12.
<h:body>
13.
<ui:composition template="./index.xhtml">
14.
<ui:define name="contenido">
15.
<h:form>
16.
<h:panelGrid columns="2" cellpadding="5">
17.
<p:outputLabel style="font-size:
1.2em;" value="Id: " />
18.
<p:inputText
value="#{jSFManagedBeanBiblioteca.id_libro}"/>
19.
20.
21.
22.
23.
24.
25.
26.
27.

<p:outputLabel style="font-size:
1.2em;" value="Ttulo: " />
<p:inputText
value="#{jSFManagedBeanBiblioteca.titulo}"/>
<p:outputLabel style="font-size:
1.2em;" value="Autor: " />
<p:inputText
value="#{jSFManagedBeanBiblioteca.autor}"/>
<p:outputLabel style="font-size:
1.2em;" value="Gnero: " />
<p:inputText
value="#{jSFManagedBeanBiblioteca.tema}"/>

28.
29.

<p:outputLabel style="font-size:
1.2em;" value="Ao: " />

30.
31.
32.

33.

34.
35.
36.
37.

38.
39.
40.

41.

<p:inputText
value="#{jSFManagedBeanBiblioteca.ao}"/>
<h:commandButton style="width: 100px;
height: 30px; font-size: 0.8em" styleClass="ui-button ui-widget
ui-state-default ui-corner-all ui-button-text-only"
value="Insertar" type="submit"
action="#{jSFManagedBeanBiblioteca.nuevoEjemplar()}"/>
<h:commandButton style="width: 100px;
height: 30px; font-size: 0.8em" styleClass="ui-button ui-widget
ui-state-default ui-corner-all ui-button-text-only"
value="Cancelar" type="submit"
action="#{jSFManagedBeanBiblioteca.reset()}"/>
</h:panelGrid>
<p colspan="2" align="center" >
<p:outputLabel style="color: red; fontsize: 1em; font-style: italic;"
value="#{jSFManagedBeanBiblioteca.mensaje}"/>
</p>
<p:dataTable
paginatorTemplate="{CurrentPageReport} {FirstPageLink}
{PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}
{RowsPerPageDropdown}"
paginatorPosition="top"
rows="10" paginator="true"

42.
43.

fallida"

emptyMessage="Bsqueda
var="libro"

44.
45.

value="#{jSFManagedBeanBiblioteca.ejemplares()}"
46.

binding="#{jSFManagedBeanBiblioteca.tabla}">
47.
48.
49.
50.
51.

<f:facet name="header">
Ejemplares
</f:facet>
<p:column headerText="Id" style="width:
5%;">

52.
53.
54.
55.

<h:outputText
value="#{libro.idLibro}" />
</p:column>
<p:column headerText="Ttulo"
style="width: 35%;">

56.
57.
58.
59.

<h:outputText
value="#{libro.titulo}" />
</p:column>
<p:column headerText="Autor"
style="width: 25%;">

60.
61.
62.

<h:outputText
value="#{libro.autor}" />
</p:column>

63.

style="width: 15%;">
64.

/>

style="width: 5%;">
68.

/>

style="width: 5%;">

77.
78.
79.
80.
81.
82.

83.
84.
85.
86.
87.
88.

89.

<p:column headerText="Ao"
<h:outputText value="#{libro.ao}"
</p:column>

69.
70.
71.

73.
74.
75.
76.

<h:outputText value="#{libro.tema}"
</p:column>

65.
66.
67.

72.

<p:column headerText="Gnero"

<p:column headerText="# Ejem."

<h:outputText
value="#{libro.ejemplares}" />
</p:column>
<p:column style="width: 10%;">
<h:commandLink
action="#{jSFManagedBeanBiblioteca.seleccionLibro()}">
Selecionar
</h:commandLink>
</p:column>
<f:facet name="footer">
Hay
#{fn:length(jSFManagedBeanBiblioteca.libros())} libros
registrados.
</f:facet>
</p:dataTable>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>

28. En el archivo Ejemmplar_Prestamo.xhtml digitaremos:


1. <?xml version='1.0' encoding='UTF-8' ?>
2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3. <html xmlns="http://www.w3.org/1999/xhtml"
4.
xmlns:h="http://xmlns.jcp.org/jsf/html"
5.
xmlns:f="http://java.sun.com/jsf/core"
6.
xmlns:p="http://primefaces.org/ui"
7.
xmlns:ui="http://java.sun.com/jsf/facelets"
8.
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
9.
<h:head>
10.
<title>TODO supply a title</title>
11.
</h:head>
12.
<h:body>
13.
<ui:composition template="./index.xhtml">
14.
<ui:define name="contenido">
15.
<h:form>
16.

17.
18.
19.
20.
21.
22.
23.

24.
25.

26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.

42.

43.
44.
45.
46.
47.

48.

<h:panelGrid columns="2" cellpadding="5">

<p:outputLabel style="font-size:
1.2em;" value="Usuario: " />
<p:selectOneMenu
value="#{jSFManagedBeanBiblioteca.id_usuario}" filter="true"
filterMatchMode="startsWith">
<f:selectItem
itemValue="#{null}" itemLabel="-- Selecionar --" />
<f:selectItems
value="#{jSFManagedBeanBiblioteca.usuarios()}" var="usuarios"
itemLabel="#{usuarios.nombre} #{usuarios.apellido}"
itemValue="#{usuarios.idSocio}" />
</p:selectOneMenu>
<p:outputLabel style="font-size:
1.2em;" value="Fecha: " />
<p:inputMask mask="9999-99-99"
value="#{jSFManagedBeanBiblioteca.fecha}"/>
<p:outputLabel style="font-size:
1.2em;" value="Id libro: " />
<p:inputMask mask=""
value="#{jSFManagedBeanBiblioteca.id_libro}"/>
<p:outputLabel style="font-size:
1.2em;" value="Id ejemplar: " />
<p:inputMask mask=""
value="#{jSFManagedBeanBiblioteca.id_ejemplar}"/>
<p:outputLabel style="font-size:
1.2em;" value="Ttulo: " />
<p:inputMask mask=""
value="#{jSFManagedBeanBiblioteca.titulo}"/>
<h:commandButton style="width: 100px;
height: 30px; font-size: 0.8em" styleClass="ui-button ui-widget
ui-state-default ui-corner-all ui-button-text-only"
value="Prestar" type="submit"
action="#{jSFManagedBeanBiblioteca.prestamo()}"/>
<h:commandButton style="width: 100px;
height: 30px; font-size: 0.8em" styleClass="ui-button ui-widget
ui-state-default ui-corner-all ui-button-text-only"
value="Cancelar" type="reset"
action="#{jSFManagedBeanBiblioteca.reset()}"/>
</h:panelGrid>
<p colspan="2" align="center" >
<p:outputLabel style="color: red; fontsize: 1em; font-style: italic;"
value="#{jSFManagedBeanBiblioteca.mensaje}"/>
</p>

49.
50.
51.
52.
53.

54.
55.
56.

<p:dataTable
paginatorTemplate="{CurrentPageReport} {FirstPageLink}
{PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}
{RowsPerPageDropdown}"
paginatorPosition="top"
rows="7" paginator="true"
var="libro"
value="#{jSFManagedBeanBiblioteca.ejemplaresDisponibles()}"

57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.

binding="#{jSFManagedBeanBiblioteca.tabla}">
<f:facet name="header">
Ejemplares de Libros Disponibles
para Prstamo
</f:facet>
<p:column headerText="Id Libro">
<h:outputText
value="#{libro.idLibro}" style="width: 5%;"/>
</p:column>
<p:column headerText="Id Ejemplar">
<h:outputText
value="#{libro.idEjemplar}" style="width: 5%;"/>
</p:column>
<p:column headerText="Ttulo">
<h:outputText
value="#{libro.titulo}" style="width: 30%;"/>
</p:column>
<p:column headerText="Autor"
style="width: 30%;">

75.
76.
77.
78.
79.

<h:outputText
value="#{libro.autor}" />
</p:column>

style="width: 15%;"/>

</p:column>

80.
81.
82.

style="width: 5%;">
83.

/>
84.
85.
86.
87.
88.
89.

<p:column headerText="Gnero">
<h:outputText value="#{libro.tema}"

<p:column headerText="Ao"
<h:outputText value="#{libro.ao}"
</p:column>

<p:column style="width: 10%;">


<h:commandLink
action="#{jSFManagedBeanBiblioteca.seleccionEjemplar()}">
Selecionar
</h:commandLink>

90.
91.
92.

</p:column>
<f:facet name="footer">
Hay
#{fn:length(jSFManagedBeanBiblioteca.ejemplaresDisponibles())}
ejemplares disponibles.
</f:facet>
</p:dataTable>

93.
94.
95.
96.
97.
98.
99.
100.
101.

102.

</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>

29. En el archivo Ejemplar_Devolucion.xhtml digitaremos:


1. <?xml version='1.0' encoding='UTF-8' ?>
2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3. <html xmlns="http://www.w3.org/1999/xhtml"
4.
xmlns:h="http://xmlns.jcp.org/jsf/html"
5.
xmlns:f="http://java.sun.com/jsf/core"
6.
xmlns:p="http://primefaces.org/ui"
7.
xmlns:ui="http://java.sun.com/jsf/facelets"
8.
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
9.
<h:head>
10.
<title>TODO supply a title</title>
11.
</h:head>
12.
<h:body>
13.
<ui:composition template="./index.xhtml">
14.
<ui:define name="contenido">
15.
<h:form>
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.

<h:panelGrid columns="2" cellpadding="5">


<p:outputLabel style="font-size:
1.2em;" value="Fecha: " />
<p:inputMask mask="9999-99-99"
value="#{jSFManagedBeanBiblioteca.fecha}"/>
<p:outputLabel style="font-size:
1.2em;" value="ID Usuario: " />
<p:inputMask mask=""
value="#{jSFManagedBeanBiblioteca.id_usuario}"/>
<p:outputLabel style="font-size:
1.2em;" value="Usuario " />
<p:inputMask mask=""
value="#{jSFManagedBeanBiblioteca.nombre}"/>
<p:outputLabel style="font-size:
1.2em;" value="Id libro: " />
<p:inputMask mask=""
value="#{jSFManagedBeanBiblioteca.id_libro}"/>

31.
32.
33.
34.
35.
36.
37.
38.

39.

40.
41.
42.
43.
44.

45.
46.
47.
48.
49.
50.

51.
52.
53.

<p:outputLabel style="font-size:
1.2em;" value="Id ejemplar: " />
<p:inputMask mask=""
value="#{jSFManagedBeanBiblioteca.id_ejemplar}"/>
<p:outputLabel style="font-size:
1.2em;" value="Ttulo: " />
<p:inputMask mask=""
value="#{jSFManagedBeanBiblioteca.titulo}"/>
<h:commandButton style="width: 100px;
height: 30px; font-size: 0.8em" styleClass="ui-button ui-widget
ui-state-default ui-corner-all ui-button-text-only"
value="Devolver" type="submit"
action="#{jSFManagedBeanBiblioteca.devolucion()}"/>
<h:commandButton style="width: 100px;
height: 30px; font-size: 0.8em" styleClass="ui-button ui-widget
ui-state-default ui-corner-all ui-button-text-only"
value="Cancelar" type="reset"
action="#{jSFManagedBeanBiblioteca.reset()}"/>
</h:panelGrid>
<p colspan="2" align="center" >
<p:outputLabel style="color: red; fontsize: 1em; font-style: italic;"
value="#{jSFManagedBeanBiblioteca.mensaje}"/>
</p>

<p:dataTable
paginatorTemplate="{CurrentPageReport} {FirstPageLink}
{PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}
{RowsPerPageDropdown}"
paginatorPosition="top"
rows="9" paginator="true"
var="devolucion"
value="#{jSFManagedBeanBiblioteca.ejemplaresDevolucion()}"

54.
55.
56.
57.
58.
59.

binding="#{jSFManagedBeanBiblioteca.tabla}">
<f:facet name="header">
Ejemplares de Libros por Devolver
</f:facet>
style="width: 5%;">

60.
61.
62.
63.

<p:column headerText="Id Libro"

<h:outputText
value="#{devolucion.idLibro }" />
</p:column>
style="width: 5%;">

<p:column headerText="Id Ejemplar"

64.
65.
66.
67.

<h:outputText
value="#{devolucion.idEjemplar}" />
</p:column>
style="width: 40%;">

68.
69.
70.
71.
72.
73.
74.
75.
76.
77.
78.
79.
80.
81.
82.
83.
84.
85.

86.
87.
88.
89.
90.
91.
92.

93.

<p:column headerText="Ttulo"

<h:outputText
value="#{devolucion.titulo}" />
</p:column>
<p:column headerText="Id Usuario">
<h:outputText
value="#{devolucion.idSocio}" style="width: 5%;"/>
</p:column>
<p:column headerText="Usuario">
<h:outputText
value="#{devolucion.nombre}" style="width: 35%;"/>
</p:column>
<p:column style="width: 10%;">
<h:commandLink
action="#{jSFManagedBeanBiblioteca.seleccionDevolucion()}">
Selecionar
</h:commandLink>
</p:column>
<f:facet name="footer">
Hay
#{fn:length(jSFManagedBeanBiblioteca.ejemplaresDevolucion())}
de ejemplares por devolver.
</f:facet>
</p:dataTable>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>

30. En el archivo Ejemplar_Reporte.xhtml digitaremos:


1. <?xml version='1.0' encoding='UTF-8' ?>
2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3. <html xmlns="http://www.w3.org/1999/xhtml"
4.
xmlns:h="http://xmlns.jcp.org/jsf/html"
5.
xmlns:f="http://java.sun.com/jsf/core"
6.
xmlns:p="http://primefaces.org/ui"
7.
xmlns:ui="http://java.sun.com/jsf/facelets"
8.
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
9.
<h:head>
10.
<title>TODO supply a title</title>
11.
</h:head>
12.
<h:body>
13.
<ui:composition template="./index.xhtml">
14.
<ui:define name="contenido">
15.
<h:form>

16.
17.
18.

fallida"
19.

<p:dataTable scrollable="true"
scrollHeight="500"
emptyMessage="Bsqueda

var="libro"
value="#{jSFManagedBeanBiblioteca.reporteEjemplares()}"

20.
21.
22.
23.
24.
25.

26.
27.
28.
29.

30.
31.
32.
33.

34.
35.
36.
37.

38.
39.
40.
41.
42.

43.
44.
45.
46.
47.
48.

49.

binding="#{jSFManagedBeanBiblioteca.tabla}">
<f:facet name="header">
Ejemplares de Libros Disponibles
</f:facet>
<p:column headerText="Id"
filterBy="#{libro.idLibro}" filterMatchMode="contains"
filterStyle="width: 75%;" style="width: 5%;">
<h:outputText
value="#{libro.idLibro}" />
</p:column>
<p:column headerText="Ttulo"
filterBy="#{libro.titulo}" filterMatchMode="contains"
filterStyle="width: 75%;" style="width: 85%;">
<h:outputText
value="#{libro.titulo}" />
</p:column>
<p:column headerText="# Ejemp."
filterBy="#{libro.ejemplares}" filterMatchMode="contains"
filterStyle="width: 75%;" style="width: 5%;">
<h:outputText
value="#{libro.ejemplares}" />
</p:column>
<p:column headerText="# Disp."
filterBy="#{libro.disponibles}" filterMatchMode="contains"
filterStyle="width: 75%;" style="width: 5%;">
<h:outputText
value="#{libro.disponibles}" />
</p:column>
<f:facet name="footer">
Hay
#{fn:length(jSFManagedBeanBiblioteca.reporteEjemplares())}
libros registrados.
</f:facet>
</p:dataTable>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>

31. En el archivo Usuarios_Todos.xhtml digitaremos:


1. <?xml version='1.0' encoding='UTF-8' ?>
2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.

33.

34.
35.
36.
37.

38.
39.

<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<h:head>
<title>TODO supply a title</title>
</h:head>
<h:body>
<ui:composition template="./index.xhtml">
<ui:define name="contenido">
<h:form >
<h:panelGrid columns="2" cellpadding="5">
<p:outputLabel style="font-size:
1.2em;" value="Id: " />
<p:inputMask mask=""
value="#{jSFManagedBeanBiblioteca.id_usuario}"/>
<p:outputLabel style="font-size:
1.2em;" value="Nombre: " />
<p:inputMask mask=""
value="#{jSFManagedBeanBiblioteca.nombre}"/>
<p:outputLabel style="font-size:
1.2em;" value="Apellido: " />
<p:inputMask mask=""
value="#{jSFManagedBeanBiblioteca.apellido}"/>
<p:outputLabel style="font-size:
1.2em;" value="Domicilio: " />
<p:inputMask mask=""
value="#{jSFManagedBeanBiblioteca.domicilio}"/>
<p:outputLabel style="font-size:
1.2em;" value="Telfono: " />
<p:inputMask mask=""
value="#{jSFManagedBeanBiblioteca.telefono}"/>
<h:commandButton style="width: 100px;
height: 30px; font-size: 0.8em" styleClass="ui-button ui-widget
ui-state-default ui-corner-all ui-button-text-only"
value="Actualizar" type="submit"
action="#{jSFManagedBeanBiblioteca.actualizarUsuario()}"/>
<h:commandButton style="width: 100px;
height: 30px; font-size: 0.8em" styleClass="ui-button ui-widget
ui-state-default ui-corner-all ui-button-text-only"
value="Cancelar" type="reset"
action="#{jSFManagedBeanBiblioteca.reset()}"/>
</h:panelGrid>
<p colspan="2" align="center" >
<p:outputLabel style="color: red; fontsize: 1em; font-style: italic;"
value="#{jSFManagedBeanBiblioteca.mensaje}"/>
</p>

40.

<p:messages id="messages" showDetail="true"


autoUpdate="true" closable="true" />

41.
42.
43.

44.
45.
46.

<p:dataTable
paginatorTemplate="{CurrentPageReport} {FirstPageLink}
{PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}
{RowsPerPageDropdown}"
rows="10" paginator="true"
paginatorPosition="top"
var="usuario"
value="#{jSFManagedBeanBiblioteca.usuarios()}"

47.
48.
49.
50.
51.
52.
53.

binding="#{jSFManagedBeanBiblioteca.tabla}">
<f:facet name="header">
Todos los Usuarios
</f:facet>
<p:column headerText="Id" style="width:
5%;">

54.
55.
56.
57.

<h:outputText
value="#{usuario.idSocio}" />
</p:column>
<p:column headerText="Nombre"
style="width: 25%;">

58.
59.
60.
61.

<h:outputText
value="#{usuario.nombre}" />
</p:column>
<p:column headerText="Apellido"
style="width: 25%;">

62.
63.
64.
65.

<h:outputText
value="#{usuario.apellido}" />
</p:column>
<p:column headerText="Domicilio"
style="width: 20%;">

66.
67.
68.
69.

<h:outputText
value="#{usuario.domicilio}" />
</p:column>
<p:column headerText="Telfono"
style="width: 15%;">

70.
71.
72.
73.
74.
75.
76.
77.
78.
79.

<h:outputText
value="#{usuario.telefono}" />
</p:column>
<p:column style="width: 10%;">
<h:commandLink
action="#{jSFManagedBeanBiblioteca.seleccionUsuario()}">
Selecionar
</h:commandLink>
</p:column>
<f:facet name="footer">

80.

81.
82.
83.
84.
85.
86.
87.

88.

Hay
#{fn:length(jSFManagedBeanBiblioteca.usuarios())} usuarios
registrados.
</f:facet>
</p:dataTable>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>

32. En el archivo Usuario_Nuevo.xhtml digitaremos:


1. <?xml version='1.0' encoding='UTF-8' ?>
2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3. <html xmlns="http://www.w3.org/1999/xhtml"
4.
xmlns:h="http://xmlns.jcp.org/jsf/html"
5.
xmlns:f="http://java.sun.com/jsf/core"
6.
xmlns:p="http://primefaces.org/ui"
7.
xmlns:ui="http://java.sun.com/jsf/facelets"
8.
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
9.
<h:head>
10.
<title>TODO supply a title</title>
11.
</h:head>
12.
<h:body>
13.
<ui:composition template="./index.xhtml">
14.
<ui:define name="contenido">
15.
<h:form >
16.
<h:panelGrid columns="2" cellpadding="5">
17.
<p:outputLabel style="font-size:
1.2em;" value="Nombre: " />
18.
<p:inputMask mask=""
value="#{jSFManagedBeanBiblioteca.nombre}"/>
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.

<p:outputLabel style="font-size:
1.2em;" value="Apellido: " />
<p:inputMask mask=""
value="#{jSFManagedBeanBiblioteca.apellido}"/>
<p:outputLabel style="font-size:
1.2em;" value="Domicilio: " />
<p:inputMask mask=""
value="#{jSFManagedBeanBiblioteca.domicilio}"/>
<p:outputLabel style="font-size:
1.2em;" value="Telfono: " />
<p:inputMask mask=""
value="#{jSFManagedBeanBiblioteca.telefono}"/>
<h:commandButton style="width: 100px;
height: 30px; font-size: 0.8em" styleClass="ui-button ui-widget
ui-state-default ui-corner-all ui-button-text-only"
value="Insertar" type="submit"
action="#{jSFManagedBeanBiblioteca.nuevoUsuario()}"/>

30.

31.
32.
33.
34.

35.
36.
37.

<h:commandButton style="width: 100px;


height: 30px; font-size: 0.8em" styleClass="ui-button ui-widget
ui-state-default ui-corner-all ui-button-text-only"
value="Cancelar" type="reset"
action="#{jSFManagedBeanBiblioteca.reset()}"/>
</h:panelGrid>
<p colspan="2" align="center" >
<p:outputLabel style="color: red; fontsize: 1em; font-style: italic;"
value="#{jSFManagedBeanBiblioteca.mensaje}"/>
</p>
<p:messages id="messages" showDetail="true"
autoUpdate="true" closable="true" />

38.
39.
40.
41.
42.

<p:dataTable

scrollable="true"
scrollHeight="240"
emptyMessage="Bsqueda

fallida"
43.
44.
45.
46.
47.
48.
49.

50.
51.
52.
53.

54.
55.
56.
57.

58.
59.
60.
61.

62.
63.
64.

var="usuario"
value="#{jSFManagedBeanBiblioteca.usuarios()}">
<f:facet name="header">
Usuarios
</f:facet>
<p:column headerText="Id"
filterBy="#{usuario.idSocio}" filterMatchMode="contains"
filterStyle="width: 75%;" style="width: 5%;">
<h:outputText
value="#{usuario.idSocio}" />
</p:column>
<p:column headerText="Nombre"
filterBy="#{usuario.nombre}" filterMatchMode="contains"
filterStyle="width: 75%;" style="width: 25%;">
<h:outputText
value="#{usuario.nombre}" />
</p:column>
<p:column headerText="Nombre"
filterBy="#{usuario.apellido}" filterMatchMode="contains"
filterStyle="width: 75%;" style="width: 25%;">
<h:outputText
value="#{usuario.apellido}" />
</p:column>
<p:column headerText="Domicilio"
filterBy="#{usuario.domicilio}" filterMatchMode="contains"
filterStyle="width: 75%;" style="width: 20%;">
<h:outputText
value="#{usuario.domicilio}" />
</p:column>

65.

66.
67.
68.
69.
70.

71.
72.
73.
74.
75.
76.
77.

78.

<p:column headerText="Telfono"
filterBy="#{usuario.telefono}" filterMatchMode="contains"
filterStyle="width: 75%;" style="width: 15%;">
<h:outputText
value="#{usuario.telefono}" />
</p:column>
<f:facet name="footer">
Hay
#{fn:length(jSFManagedBeanBiblioteca.usuarios())} usuarios
registrados.
</f:facet>
</p:dataTable>
</h:form>
</ui:define>
</ui:composition>
</h:body>
</html>

Conclusin
Hemos diseado una aplicacin con JavaService Faces que automatizar conexin,
insercin, actualizacin y consulta de los datos generados por los movimientos
realizados en la gestin de una biblioteca.

Capturas de todos los mdulos del Sistema


INICIO:

LIBROS:

NUEVO LIBRO:

EJEMPLARES:

NUEVO EJEMPLAR:

PRESTAMO EJEMPLAR:

DEVOLUCIN EJEMPLAR:

REPORTE EJEMPLARES:

USUARIOS:

NUEVO USUARIO:

Anda mungkin juga menyukai