Browse Source

Mejoras del login, y cambios de datos de productos

master
IVAN ALEJANDRO PADILLA CORDOVA 4 months ago
parent
commit
dc694258d1
  1. 17
      Inventario-war/src/java/mx/edu/tsj/chapala/sistemas/inventario/seguridad/Login.java
  2. 5
      Inventario-war/web/WEB-INF/web.xml
  3. 35
      Inventario-war/web/error.xhtml
  4. 20
      Inventario-war/web/login.xhtml
  5. 8
      Inventario-war/web/productosCrear.xhtml
  6. 3
      Inventario-war/web/productosEliminar.xhtml
  7. 3
      Inventario-war/web/productosLista.xhtml
  8. 15
      Inventario-war/web/template/principal.xhtml
  9. 15
      Inventario-war/web/template/productosP.xhtml
  10. 2
      Inventario-war/web/usuarioCrear.xhtml

17
Inventario-war/src/java/mx/edu/tsj/chapala/sistemas/inventario/seguridad/Login.java

@ -1,10 +1,12 @@
package mx.edu.tsj.chapala.sistemas.inventario.seguridad; package mx.edu.tsj.chapala.sistemas.inventario.seguridad;
import java.io.IOException;
import javax.inject.Named; import javax.inject.Named;
import javax.enterprise.context.SessionScoped; import javax.enterprise.context.SessionScoped;
import java.io.Serializable; import java.io.Serializable;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage; import javax.faces.application.FacesMessage;
import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext; import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import mx.edu.tsj.chapala.sistemas.inventario.modelo.bl.UsuariosBL; import mx.edu.tsj.chapala.sistemas.inventario.modelo.bl.UsuariosBL;
@ -26,6 +28,19 @@ public class Login implements Serializable {
public void init() { public void init() {
usuariosBL = new UsuariosBL(); // O cualquier método adecuado para inicializar usuariosBL usuariosBL = new UsuariosBL(); // O cualquier método adecuado para inicializar usuariosBL
} }
//Codigo de Exceptions:
public String handleViewExpiredException() {
FacesContext context = FacesContext.getCurrentInstance();
ExternalContext externalContext = context.getExternalContext();
try {
externalContext.redirect(externalContext.getRequestContextPath() + "login.xhtml");
} catch (IOException e) {
// Manejar la excepción de redirección
e.printStackTrace();
}
context.responseComplete();
return null;
}
public static void getSesion(){ public static void getSesion(){
httpSession = (HttpSession) httpSession = (HttpSession)
@ -33,8 +48,10 @@ public class Login implements Serializable {
} }
public static String logout(){ public static String logout(){
httpSession.removeAttribute("sesionActiva"); httpSession.removeAttribute("sesionActiva");
httpSession.invalidate(); httpSession.invalidate();
FacesContext.getCurrentInstance().getExternalContext().invalidateSession();
return "login.xhtml"; return "login.xhtml";
} }
public void limpiarCampos() { public void limpiarCampos() {

5
Inventario-war/web/WEB-INF/web.xml

@ -18,6 +18,11 @@
30 30
</session-timeout> </session-timeout>
</session-config> </session-config>
<error-page>
<exception-type>javax.faces.application.ViewExpiredException</exception-type>
<location>/error.xhtml</location>
</error-page>
<welcome-file-list> <welcome-file-list>
<welcome-file>faces/productosLista.xhtml</welcome-file> <welcome-file>faces/productosLista.xhtml</welcome-file>
</welcome-file-list> </welcome-file-list>

35
Inventario-war/web/error.xhtml

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Error</title>
<style>
body {
background-image: url('../resources/css/images/fondoLogin3.png');
background-size: auto;
background-position: center;
background-repeat: no-repeat;
font-family: Arial, sans-serif; /* Cambia la fuente según necesites */
margin: 0;
padding: 0;
}
</style>
</h:head>
<h:body>
<center>
<h1>Error</h1>
<p>Se ha detectado un error. Por favor, vuelve hacia atras y recarga la página e intenta de nuevo.</p>
<p><strong>Nota:</strong> Si el problema persiste, por favor, contacta al administrador del sistema.</p>
</center>
<f:view>
<h:form>
<h:commandButton value="Recargar página" action="#{facesContext.externalContext.redirect(facesContext.externalContext.requestContextPath + '/login.xhtml')}" style="background-color: blue; color: white;" />
</h:form>
</f:view>
</h:body>
</html>

20
Inventario-war/web/login.xhtml

@ -7,6 +7,23 @@
<h:head> <h:head>
<title>Inicio de sesión</title> <title>Inicio de sesión</title>
<h:outputStylesheet library="css" name="styles.css" /> <h:outputStylesheet library="css" name="styles.css" />
<script>
// Deshabilitar la navegación hacia atrás
history.pushState(null, null, document.URL);
window.addEventListener('popstate', function () {
history.pushState(null, null, document.URL);
});
// Deshabilitar la navegación hacia adelante
window.addEventListener('load', function () {
if (window.history.forward(1) !== null) {
window.history.forward(1);
}
});
</script>
<style> <style>
body { body {
background-image: url('../resources/css/images/fondoLogin3.png'); background-image: url('../resources/css/images/fondoLogin3.png');
@ -22,6 +39,9 @@
</h:head> </h:head>
<h:body> <h:body>
<h:form id="loginForm"> <h:form id="loginForm">
<f:metadata>
<f:viewAction action="#{demoBeanLogin.handleViewExpiredException}" />
</f:metadata>
<p:growl id="growl" showDetail="true" /> <p:growl id="growl" showDetail="true" />
<h2 style="margin-bottom: 40px;">Iniciar sesión</h2> <h2 style="margin-bottom: 40px;">Iniciar sesión</h2>
<h:panelGrid columns="2" id="loginPanel"> <h:panelGrid columns="2" id="loginPanel">

8
Inventario-war/web/productosCrear.xhtml

@ -93,7 +93,8 @@
<div> <div>
<p:outputLabel value="Precio:" for="precio" /> <p:outputLabel value="Precio:" for="precio" />
<p:inputText id="precio" value="#{demoBeanProductos.producto.precio}" style="margin-left: 10px; margin-right: 60px; margin-bottom: 20px" title="Precio" required="true" validatorMessage="Se requiere campo Valido en Precio" requiredMessage="Se requiere campo Precio."> <p:inputText id="precio" value="#{demoBeanProductos.producto.precio}" style="margin-left: 10px; margin-right: 60px; margin-bottom: 20px" title="Precio" required="true" validatorMessage="Se requiere campo Valido en Precio" requiredMessage="Se requiere campo Precio.">
<f:validateRegex pattern="^\d+(\.\d+)?$" /> <f:validateRegex pattern="^(?!0+(\.0+)?$)\d+(\.\d+)?$" />
</p:inputText> </p:inputText>
<p:outputLabel value="Material:" for="material" /> <p:outputLabel value="Material:" for="material" />
@ -145,8 +146,8 @@
</p:selectOneMenu> </p:selectOneMenu>
</div> </div>
<div> <div>
<p:outputLabel value="Ubicacion:" for="ubicacionid" /> <p:outputLabel value="Almacén:" for="ubicacionid" />
<p:selectOneMenu id="ubicacionid" value="#{demoBeanProductos.producto.ubicacionid}" converter="selectOneMenuConverter" style="margin-left: 20px; margin-right: -210px; margin-bottom: 20px" title="Ubicacionid" required="true" requiredMessage="Se requiere campo Ubicacion." appendTo="@this"> <p:selectOneMenu id="ubicacionid" value="#{demoBeanProductos.producto.ubicacionid}" converter="selectOneMenuConverter" style="margin-left: 20px; margin-right: -210px; margin-bottom: 20px" title="Ubicacionid" required="true" requiredMessage="Se requiere campo Almacén." appendTo="@this">
<f:selectItems value="#{demoBeanUbicacion.listUbicacion}" var="itemU" itemLabel="#{itemU.nombreAlmacen}" itemValue="#{itemU}"/> <f:selectItems value="#{demoBeanUbicacion.listUbicacion}" var="itemU" itemLabel="#{itemU.nombreAlmacen}" itemValue="#{itemU}"/>
</p:selectOneMenu> </p:selectOneMenu>
@ -166,5 +167,6 @@
</ui:composition> </ui:composition>
</body> </body>
</html> </html>

3
Inventario-war/web/productosEliminar.xhtml

@ -116,7 +116,7 @@
<h:outputText value="Talla:"/> <h:outputText value="Talla:"/>
<p:inputText value="#{demoBeanProductos.producto.tallaid.talla}" style="margin-left: 10px; margin-right: 30px; margin-bottom: 20px" disabled="true" title="Tallaid"/> <p:inputText value="#{demoBeanProductos.producto.tallaid.talla}" style="margin-left: 10px; margin-right: 30px; margin-bottom: 20px" disabled="true" title="Tallaid"/>
<h:outputText value="Ubicacion:"/> <h:outputText value="Almacén:"/>
<p:inputText value="#{demoBeanProductos.producto.ubicacionid.nombreAlmacen}" style="margin-left: 10px; margin-right: 60px; margin-bottom: 20px" disabled="true" title="Ubicacionid"/> <p:inputText value="#{demoBeanProductos.producto.ubicacionid.nombreAlmacen}" style="margin-left: 10px; margin-right: 60px; margin-bottom: 20px" disabled="true" title="Ubicacionid"/>
</div> </div>
@ -131,5 +131,6 @@
</ui:composition> </ui:composition>
</body> </body>
</html> </html>

3
Inventario-war/web/productosLista.xhtml

@ -153,7 +153,7 @@
</p:column> </p:column>
<p:column styleClass="salto"> <p:column styleClass="salto">
<f:facet name="header" > <f:facet name="header" >
<h:outputText value="Ubicacion" style="text-align: center;"/> <h:outputText value="Almacén" style="text-align: center;"/>
</f:facet> </f:facet>
<h:outputText value="#{item.ubicacionid.nombreAlmacen}"/> <h:outputText value="#{item.ubicacionid.nombreAlmacen}"/>
</p:column> </p:column>
@ -186,5 +186,6 @@
</body> </body>
</html> </html>

15
Inventario-war/web/template/principal.xhtml

@ -15,7 +15,20 @@
<link href="https://cdn.datatables.net/v/dt/dt-2.0.3/datatables.min.css" rel="stylesheet"/> <link href="https://cdn.datatables.net/v/dt/dt-2.0.3/datatables.min.css" rel="stylesheet"/>
<script src="https://cdn.datatables.net/v/dt/dt-2.0.3/datatables.min.js"></script> <script src="https://cdn.datatables.net/v/dt/dt-2.0.3/datatables.min.js"></script>
<script>
// Deshabilitar la navegación hacia atrás
history.pushState(null, null, document.URL);
window.addEventListener('popstate', function () {
history.pushState(null, null, document.URL);
});
// Deshabilitar la navegación hacia adelante
window.addEventListener('load', function () {
if (window.history.forward(1) !== null) {
window.history.forward(1);
}
});
</script>
</h:head> </h:head>

15
Inventario-war/web/template/productosP.xhtml

@ -15,7 +15,20 @@
<script src="https://cdn.datatables.net/v/dt/dt-2.0.3/datatables.min.js"></script> <script src="https://cdn.datatables.net/v/dt/dt-2.0.3/datatables.min.js"></script>
<title>Facelets Template</title> <title>Facelets Template</title>
<script>
// Deshabilitar la navegación hacia atrás
history.pushState(null, null, document.URL);
window.addEventListener('popstate', function () {
history.pushState(null, null, document.URL);
});
// Deshabilitar la navegación hacia adelante
window.addEventListener('load', function () {
if (window.history.forward(1) !== null) {
window.history.forward(1);
}
});
</script>
</h:head> </h:head>

2
Inventario-war/web/usuarioCrear.xhtml

@ -79,7 +79,7 @@
<p:inputText id="usuario" value="#{demoBeanUsuarios.usuario.usuario}" style="margin: 20px" title="Usuario" required="true" requiredMessage="Se requiere campo Usuario."/> <p:inputText id="usuario" value="#{demoBeanUsuarios.usuario.usuario}" style="margin: 20px" title="Usuario" required="true" requiredMessage="Se requiere campo Usuario."/>
<p:outputLabel value="Contraseña:" for="password" /> <p:outputLabel value="Contraseña:" for="password" />
<p:inputText id="password" value="#{demoBeanUsuarios.usuario.password}" style="margin-left: 20px; margin-right: 10px; margin-bottom: 20px" title="password" required="true" validatorMessage="La Contraseña no es valido" requiredMessage="Se requiere el campo Contraseña."> <p:inputText id="password" value="#{demoBeanUsuarios.usuario.password}" style="margin-left: 20px; margin-right: 10px; margin-bottom: 20px" title="password" required="true" validatorMessage="La Contraseña no es valido. Debe contener al menos una letra mayúscula, una letra minúscula, un número y tener una longitud mínima de 8 caracteres." requiredMessage="Se requiere el campo Contraseña.">
<f:validateRegex pattern="^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$" for="password"/> <f:validateRegex pattern="^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)[a-zA-Z\d]{8,}$" for="password"/>
</p:inputText> </p:inputText>
</div> </div>

Loading…
Cancel
Save