package inukisoft.patronesj2ee.view.beans; import inukisoft.util.ValidationSet; import javax.servlet.http.HttpServletRequest; import org.apache.struts.action.ActionError; import org.apache.struts.action.ActionErrors; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForm; /** *

Subclase de ActionForm que implementa un JavaBean (denominado BeanForm) * que gestiona los datos de un formulario. Este tipo de clases ayuda a implementar * el patrón View Helper, puesto que elimina el scriptlet del formulario * y centraliza las validaciones en clases Java (javabeans).

*

Este beanForm gestion los datos de la consulta

* @author Constantino Samuel Alarcón Mery * @version 1.0 */ public class ProductoSoftwareForm extends ActionForm { private String id; private String nombre; private String descripcion; private String precio; public void setId(String id) { this.id = id; } public void setNombre(String nombre) { this.nombre = nombre; } public void setDescripcion(String descripcion) { this.descripcion = descripcion; } public void setPrecio(String precio) { this.precio = precio; } public String getId() { return this.id; } public String getNombre() { return this.nombre; } public String getDescripcion() { return this.descripcion; } public String getPrecio() { return this.precio; } public ActionErrors validate(ActionMapping mapping,HttpServletRequest request) { ActionErrors errors = new ActionErrors(); if (!ValidationSet.betweenLength(getNombre(),1,50)) { errors.add("nombre",new ActionError("error.nombrelength")); } if (!ValidationSet.betweenLength(getDescripcion(),10,1000)) { errors.add("descripcion",new ActionError("error.descripcionlength")); } if (!ValidationSet.isMoney(getPrecio())) { errors.add("precio",new ActionError("error.malformedprecio")); } return errors; } }