@Override
  protected Object resolveVariable(ELContext elContext, String varName) {

    Object value = null;

    try {

      if (varName.equals(VAR_NAME_I18N)) {

        if (i18n == null) {
          i18n = new I18N();
        }

        value = i18n;
      }
    } catch (Exception e) {
      throw new ELException("Failed to resolve variable [" + varName + "]", e);
    }

    if (value == null) {

      if (logger.isDebugEnabled()) {
        logger.debug("Unable to resolve variable [" + varName + "] value=" + value);
      }
    } else {

      if (logger.isDebugEnabled()) {
        logger.debug("Resolved variable [" + varName + "] value=" + value);
      }
    }

    return value;
  }
  public void afterPhase(PhaseEvent phaseEvent) {

    // This method just does some logging. It's useful to the developer to determine if a
    // navigation-rule
    // fired, causing new JSF view to be restored after the INVOKE_APPLICATION phase finished.
    if (logger.isDebugEnabled() && (phaseEvent.getPhaseId() == PhaseId.INVOKE_APPLICATION)) {
      FacesContext facesContext = phaseEvent.getFacesContext();
      String viewId = facesContext.getViewRoot().getViewId();
      logger.debug("After INVOKE_APPLICATION: viewId=[{0}]", viewId);
    }
  }
  public String submit() {

    if (logger.isDebugEnabled()) {
      logger.debug("firstName=" + applicantModelBean.getFirstName());
      logger.debug("lastName=" + applicantModelBean.getLastName());
      logger.debug("emailAddress=" + applicantModelBean.getEmailAddress());
      logger.debug("phoneNumber=" + applicantModelBean.getPhoneNumber());
      logger.debug("dateOfBirth=" + applicantModelBean.getDateOfBirth());
      logger.debug("city=" + applicantModelBean.getCity());
      logger.debug("provinceId=" + applicantModelBean.getProvinceId());
      logger.debug("postalCode=" + applicantModelBean.getPostalCode());
      logger.debug("comments=" + applicantModelBean.getComments());

      List<UploadedFile> uploadedFiles = applicantModelBean.getUploadedFiles();

      for (UploadedFile uploadedFile : uploadedFiles) {
        logger.debug("uploadedFile=[{0}]", uploadedFile.getName());
      }
    }

    // Delete the uploaded files.
    try {
      List<UploadedFile> uploadedFiles = applicantModelBean.getUploadedFiles();

      for (UploadedFile uploadedFile : uploadedFiles) {
        File file = new File(uploadedFile.getAbsolutePath());
        file.delete();
        logger.debug("Deleted file=[{0}]", file);
      }

      // Store the applicant's first name in JSF 2 Flash Scope so that it can be picked up
      // for use inside of confirmation.xhtml
      FacesContext facesContext = FacesContext.getCurrentInstance();
      facesContext
          .getExternalContext()
          .getFlash()
          .put("firstName", applicantModelBean.getFirstName());

      applicantModelBean.clearProperties();

      return "success";

    } catch (Exception e) {
      logger.error(e.getMessage(), e);
      FacesMessageUtil.addGlobalUnexpectedErrorMessage(FacesContext.getCurrentInstance());

      return "failure";
    }
  }