package examples;
import org.apache.struts.action.*;

import javax.servlet.http.HttpServletRequest;

public class LoginForm extends ActionForm {

    private String username;
    private String password;

    public void setUsername(String username) {
        this.username = username;
    }

    public String getUsername() {
        return this.username;
    }

    public String getPassword() {
        return this.password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public ActionErrors validate(ActionMapping mapping,
                                 HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        if ((username == null) || (username.length() < 1))
            errors.add("username",new ActionError("error.username.required"));
        if ((password == null) || (password.length() < 1))
            errors.add("password",new ActionError("error.password.required"));
	if (errors.isEmpty())
	    return null;
	else
	    return errors;
    }

}

