Package org.apache.struts.util

Examples of org.apache.struts.util.ErrorMessages


  Locale locale = getLocale(request);
  MessageResources messages = getResources(servlet);
  User user = null;

  // Validate the request parameters specified by the user
  ErrorMessages errors = new ErrorMessages();
  String username = ((LogonForm) form).getUsername();
  String password = ((LogonForm) form).getPassword();
  Hashtable database = (Hashtable)
    servlet.getServletContext().getAttribute(Constants.DATABASE_KEY);
  if (database == null)
      errors.addError("error.database.missing");
  else {
      user = (User) database.get(username);
      if ((user != null) && !user.getPassword().equals(password))
    user = null;
      if (user == null)
    errors.addError("error.password.mismatch");
  }

  // Report any errors we have discovered back to the original form
  if (errors.getSize() > 0) {
      saveErrors(request, errors);
      return (new ActionForward(mapping.getInputForm()));
  }

  // Save our logged-in user in the session
View Full Code Here


     * Validate the properties of this form bean, and return an array of
     * message keys for any errors we encounter.
     */
    public String[] validate() {

  ErrorMessages errors = new ErrorMessages();
  if ((username == null) || (username.length() < 1))
      errors.addError("error.username.required");
  if (!password.equals(password))
      errors.addError("error.password.match");
  if ((fromAddress == null) || (fromAddress.length() < 1))
      errors.addError("error.fromAddress.required");
  else {
      int atSign = fromAddress.indexOf("@");
      if ((atSign < 1) || (atSign >= (fromAddress.length() - 1)))
    errors.addError("error.fromAddress.format");
  }
  if ((fullName == null) || (fullName.length() < 1))
      errors.addError("error.fullName.required");
  if ((replyToAddress != null) && (replyToAddress.length() > 0)) {
      int atSign = replyToAddress.indexOf("@");
      if ((atSign < 1) || (atSign >= (replyToAddress.length() - 1)))
    errors.addError("error.replyToAddress.format");
  }

  return (errors.getErrors());

    }
View Full Code Here

     * Validate the properties of this form bean, and return an array of
     * message keys for any errors we encounter.
     */
    public String[] validate() {

  ErrorMessages errors = new ErrorMessages();
  if ((host == null) || (host.length() < 1))
      errors.addError("error.host.required");
  if ((username == null) || (username.length() < 1))
      errors.addError("error.username.required");
  if ((password == null) || (password.length() < 1))
      errors.addError("error.password.required");
  if ((type == null) || (type.length() < 1))
      errors.addError("error.type.required");
  else if (!"imap".equals(type) && !"pop3".equals(type))
      errors.addError("error.type.invalid");

  return (errors.getErrors());

    }
View Full Code Here

  // All required validations were done in the form bean

  // Validate the request parameters specified by the user
  String value = null;
  ErrorMessages errors = new ErrorMessages();
  value = regform.getUsername();
  if (("Create".equals(action)) &&
      (database.get(value) != null))
      errors.addError("error.username.unique");
  if ("Create".equals(action)) {
      value = regform.getPassword();
      if ((value == null) || (value.length() <1))
    errors.addError("error.password.required");
      value = regform.getPassword2();
      if ((value == null) || (value.length() < 1))
    errors.addError("error.password2.required");
  }

  // Report any errors we have discovered back to the original form
  if (errors.getSize() > 0) {
      saveErrors(request, errors);
      return (new ActionForward(mapping.getInputForm()));
  }

  // Update the user's persistent profile information
View Full Code Here

TOP

Related Classes of org.apache.struts.util.ErrorMessages

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.