Ok... mayby that an example

This is a posible ActionForm..... the variable "flag" indicates the type of
validation that needs

public class CosaForm extends ActionForm {

      private String nombre = "";
      private String apellidos = "";
      private String telefono = "";
      private String direccion = "";
      private String flag = ""; //The hidden field

      public void reset(ActionMapping arg0, HttpServletRequest arg1) {
            nombre = "";
            apellidos = "";
            telefono = "";
             direccion = "";
      }

      public ActionErrors validate(ActionMapping arg0, HttpServletRequest
arg1) {
            ActionErrors errors = new ActionErrors();

            if(flag.equals("onlyName")){
                  if(nombre.trim().length() == 0)
                        errors.add("validaForm", new ActionError
("error.name.void"));

            else if(flag.equals("onlyAddresTelephone")){
                  if(direccion.trim().length() == 0)
                        errors.add("validaForm", new ActionError
("error.addres.void"));

                  else if(telefono.trim().length() == 0 || telefono.trim
().length() > 9)
                        errors.add("validaForm", new ActionError
("error.thelepone"));
              }

            return errors;
      }



      /**
       *
       */
      public AnadirForm() {
      }

      public String getApellidos() {return apellidos;}
      public void setApellidos(String apellidos) {this.apellidos =
apellidos;}
      public String getNombre() {return nombre;}
      public void setNombre(String nombre) {this.nombre = nombre;}
      public String getTelefono() {return telefono;}
      public void setTelefono(String telefono) {this.telefono = telefono;}
      public String getDireccion() {return direccion;}
      public void setDireccion(String direccion) {this.direccion =
direccion;}

}



|---------+---------------------------->
|         |           Rafael Taboada   |
|         |           <kaliman.forever@|
|         |           gmail.com>       |
|         |                            |
|         |           15/07/2005 14:20 |
|         |           Please respond to|
|         |           "Struts Users    |
|         |           Mailing List"    |
|         |                            |
|         |                            |
|         |                            |
|         |                            |
|---------+---------------------------->
  
>--------------------------------------------------------------------------------------------------------------------------------|
  |                                                                             
                                                   |
  |       To:       Struts Users Mailing List <user@struts.apache.org>          
                                                   |
  |       cc:                                                                   
                                                   |
  |       bcc:                                                                  
                                                   |
  |       Subject:  Re: Some advice                                             
                                                   |
  
>--------------------------------------------------------------------------------------------------------------------------------|




Hi Basudeb Acharya for ur help... It's really that I want =)
 Ex.llitia2. I'd like you are more specific. My code in ActionForm is:
 ActionErrors errors = ventaForm.validate(mapping,request);

if (errors==null || errors.isEmpty()) {
 //Do something because all is OK
}
else
saveErrors(request,errors);


--
Rafael Taboada
Software Engineer

Cell : +511-97753290

"No creo en el destino pues no me gusta tener la idea de controlar mi vida"






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to