Gestin de
Biblioteca
Servicios |
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
2.
3.
4.
5.
6.
DIAGRAMA ENTIDAD-RELACIN:
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.
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.
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. }
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:
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.
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;
}
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.
}
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>
19.
20.
21.
<p:inputText
value="#{jSFManagedBeanBiblioteca.titulo}"/>
22.
23.
24.
<p:inputText
value="#{jSFManagedBeanBiblioteca.autor}"/>
25.
26.
27.
<p:inputText
value="#{jSFManagedBeanBiblioteca.tema}"/>
28.
29.
30.
31.
32.
<p:inputText
value="#{jSFManagedBeanBiblioteca.ao}"/>
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>
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.
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>
<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"
<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>
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.
<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>
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>
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.
<h:outputText
value="#{devolucion.idLibro }" />
</p:column>
style="width: 5%;">
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>
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>
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.
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>
<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.
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.
LIBROS:
NUEVO LIBRO:
EJEMPLARES:
NUEVO EJEMPLAR:
PRESTAMO EJEMPLAR:
DEVOLUCIN EJEMPLAR:
REPORTE EJEMPLARES:
USUARIOS:
NUEVO USUARIO: