Package com.gtp.controller

Source Code of com.gtp.controller.ReminderController

package com.gtp.controller;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.mail.MessagingException;

import com.gtp.domain.User;
import com.gtp.service.ReminderService;
import commons.NotFoundException;

public class ReminderController {
  String email,secretQuestion,secretAnswer;
  ReminderService reminderService;
  public String remind(){
    User user=new User();
    user.setEmail(email);
    user.setSecretQuestion(secretQuestion);
    user.setSecretAnswer(secretAnswer);
    try {
      try {
        reminderService.remindPassword(user);
      } catch (MessagingException e) {
        FacesContext.getCurrentInstance().addMessage(null,
            new FacesMessage(FacesMessage.SEVERITY_ERROR,
            "Mail was not sent",""));
        e.printStackTrace();
        return null;
      }
    } catch (NotFoundException e) {
      FacesContext.getCurrentInstance().addMessage(null,
          new FacesMessage(FacesMessage.SEVERITY_WARN,
          "wrong email adress",""));
      e.printStackTrace();
      return null;
    }
    FacesContext.getCurrentInstance().addMessage(null,
        new FacesMessage(FacesMessage.SEVERITY_INFO,
        """Successful"));
    return null;
  }
 
  public ReminderService getReminderService() {
    return reminderService;
  }
  public void setReminderService(ReminderService reminderService) {
    this.reminderService = reminderService;
  }
  public String getEmail() {
    return email;
  }
  public void setEmail(String email) {
    this.email = email;
  }
  public String getSecretAnswer() {
    return secretAnswer;
  }
  public void setSecretAnswer(String secretAnswer) {
    this.secretAnswer = secretAnswer;
  }
  public String getSecretQuestion() {
    return secretQuestion;
  }
  public void setSecretQuestion(String secretQuestion) {
    this.secretQuestion = secretQuestion;
  }
}
TOP

Related Classes of com.gtp.controller.ReminderController

TOP
Copyright © 2018 www.massapi.com. 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.