Developer's Daily Java Education - Test Projects
  front page | java | perl | unix | DevDirectory
   
Front Page
Java
Education
   
 


package com.devdaily.strutstest.form;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionMapping;

public class LoginForm extends ActionForm
{

  private String username;
  private String password;

  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request)
  {
    System.err.println( "Entered LoginForm.validate() ..." );
    ActionErrors errors = new ActionErrors();
    if ( username==null || username.trim().equals("") )  errors.add("username", new ActionError("username"));
    if ( password==null || password.trim().equals("") )  errors.add("password", new ActionError("password"));
    System.err.println( "Leaving LoginForm.validate ..." );
    return errors;
  }

  public void setUsername(String newUsername)
  {
    username = newUsername;
  }
  public String getUsername()
  {
    return username;
  }
  public void setPassword(String newPassword)
  {
    password = newPassword;
  }
  public String getPassword()
  {
    return password;
  }


}
Copyright 1998-2003 DevDaily Interactive, Inc.
All Rights Reserved.