Exemple #1
0
 String onSuccess() throws RemoteException {
   try {
     visitor.setConfig(service.getSOInterfaceConfiguration(visitor.getId()));
     if (!visitor.getConfig().isLicenseAvailable()) {
       form.recordError(messages.get("license-expired-text"));
       return null;
     }
     if (!service.login(visitor.getId(), visitor.getPassword())) {
       form.recordError(messages.get("login-failed-message"));
       return null;
     }
     logout();
     if (visitor.getLocale() == null) {
       visitor.setLocale(new Locale(visitor.getConfig().getDefaultLanguage()));
     }
     persistentLocale.set(visitor.getLocale());
     setUser(visitor);
     // FIXME: commented out beccause some pages(eg, newsalesorder) requires an use coming
     // from a specific page(eg, customer/search).
     // if (sourcePage != null) {
     // return sourcePage;
     // }
     // A complete solution would be to define the relationships between pages
     // in some way, and use that to figure out which page to redirect to. However,
     // it's out of the scope of current requirement... .
     return "customer/search";
   } finally {
     visitor = null;
   }
 }
  void onValidateFromLoginForm() {

    if (!loginForm.isValid()) {
      return;
    }

    try {
      userProfile = userService.login(loginName, password, false);
    } catch (InstanceNotFoundException e) {
      loginForm.recordError(messages.get("error-authenticationFailed"));
    } catch (IncorrectPasswordException e) {
      loginForm.recordError(messages.get("error-authenticationFailed"));
    }
  }
Exemple #3
0
  @Override
  protected void processSubmission(String elementName) {
    String value = request.getParameter(elementName);

    tracker.recordInput(this, value);

    updateClientTimeZone(elementName);

    Date parsedValue = null;

    try {
      if (InternalUtils.isNonBlank(value)) {
        // Regardless of the timeZone set on the DateFormat, the value is parsed in
        // the current default TimeZone. Use the calendar to adjust it out.

        Date inDefaultTimeZone = format.parse(value);

        parsedValue = convertDateToClientTimeZone(inDefaultTimeZone);
      }
    } catch (ParseException ex) {
      tracker.recordError(this, messages.format("tapx-date-value-not-parseable", value));
      return;
    }

    try {
      fieldValidationSupport.validate(parsedValue, resources, validate);

    } catch (ValidationException ex) {
      tracker.recordError(this, ex.getMessage());

      return;
    }

    if (min != null && parsedValue.before(min)) {
      tracker.recordError(this, messages.get("tapx-date-value-to-early"));
      return;
    }

    if (max != null && parsedValue.after(max)) {
      tracker.recordError(this, messages.get("tapx-date-value-too-late"));
      return;
    }

    this.value = parsedValue;
  }
 public String getFormattedExpiryDate() {
   if (detailedUser.getExpirationDate() != null) {
     String dateFormat = messages.get("global.pattern.date");
     SimpleDateFormat dateFormatter = new SimpleDateFormat(dateFormat);
     return dateFormatter.format(detailedUser.getExpirationDate());
   } else {
     return "";
   }
 }
Exemple #5
0
  Object defaultBlankLabel() {
    Messages containerMessages = resources.getContainerMessages();

    String key = resources.getId() + "-blanklabel";

    if (containerMessages.contains(key)) return containerMessages.get(key);

    return null;
  }
  public void send(User user, String subject, String message, String url, boolean hint)
      throws UsernameNotFoundException, MailException {

    StringBuilder msg = new StringBuilder(message);
    if (!hint) {
      msg.append("\n\n").append(messages.get("user.username"));
      msg.append(": ").append(user.getUsername()).append("\n");
      msg.append(messages.get("user.password")).append(": ");
      msg.append(user.getPassword());
    }
    msg.append("\n\nLogin at: ").append(url);

    simpleMailMessage.setTo(user.getFullName() + "<" + user.getEmail() + ">");
    simpleMailMessage.setSubject(subject);
    simpleMailMessage.setText(msg.toString());

    mailEngine.send(simpleMailMessage);
  }
Exemple #7
0
  Object onActivate() {
    String ret = "";
    String serviceType = request.getParameter("serviceType");
    String param = request.getParameter("optionValue");
    String type = "";
    try {
      if ("getCities".equalsIgnoreCase(serviceType)) {
        ret = getAddressUtils().getCitiesByProvince(param);
        type = messages.get("chooseCity");
      }

      if ("getCounties".equalsIgnoreCase(serviceType)) {
        ret = getAddressUtils().getCountiesByCity(param);
        type = messages.get("chooseCounty");
      }
    } catch (Exception e) {
      e.printStackTrace();
    }

    return new TextStreamResponse("text/plain", getStringWithLabels(ret, type));
  }
 /**
  * Check the contact form
  *
  * @throws ValidationException
  * @throws RemoteException
  */
 void onValidateFromContactForm() throws ValidationException, RemoteException {
   // personNumber can not be duplicated.
   if (isNewContact) {
     for (Contact con : contacts) {
       if (con.getPersonNumber() == contactEdited.getPersonNumber()) {
         throw new ValidationException(messages.get("person-number-already-exist-message"));
       }
     }
   }
   if (isApplyingContact || isDeleteContact) {
     // personNumber can be 0 in Sylvestrix
     if (contacts == null || contacts.size() == 0 || !contactSelected()) {
       throw new ValidationException(messages.get("select-row-message"));
     }
     if (isApplyingContact) {
       for (Contact con : contacts) {
         if (con.getContactId() != editContactId
             && con.getPersonNumber() == contactEdited.getPersonNumber()) {
           throw new ValidationException(messages.get("person-number-already-exist-message"));
         }
         // personal number can not be changed.
         if (con.getContactId() == editContactId
             && con.getPersonNumber() != contactEdited.getPersonNumber()) {
           throw new ValidationException(
               messages.get("person-number-can-not-be-changed-on-web-message"));
         }
       }
     }
     if (isDeleteContact) {
       boolean canContactBeDeleted =
           service.canContactBeDeleted(customer.getNumber(), contactEdited.getPersonNumber());
       if (!canContactBeDeleted) {
         throw new ValidationException(messages.get("contact-can-not-be-deleted-message"));
       }
     }
   }
 }
Exemple #9
0
  private String getStringWithLabels(String originalStr, String type) {
    String[] originalArr = StringUtils.split(originalStr, ",");
    StringBuilder builder = new StringBuilder();

    builder =
        builder
            .append("{ ")
            .append("\"value\"")
            .append(":")
            .append("\"\",")
            .append("\"label\"")
            .append(":")
            .append("\"")
            .append(type)
            .append("\"")
            .append(" }")
            .append("|");

    for (int i = 0; i < originalArr.length; i++) {
      builder
          .append("{ ")
          .append("\"value\"")
          .append(":")
          .append("\"")
          .append(originalArr[i])
          .append("\"")
          .append(",")
          .append("\"label\"")
          .append(":")
          .append("\"")
          .append(messages.get(originalArr[i]))
          .append("\"")
          .append(" }")
          .append("|");
    }
    System.out.println("**** " + builder.toString());
    return StringUtils.removeEnd(builder.toString(), "|");
  }
 public Object onException(Throwable cause) {
   shareSessionObjects.addError(messages.get("global.exception.message"));
   logger.error(cause.getMessage());
   cause.printStackTrace();
   return this;
 }
  private JSONObject setI18NMessages() {
    JSONObject language = new JSONObject();
    language.put("sProcessing", messages.get("datatable.sProcessing"));
    language.put("sSearch", messages.get("datatable.sSearch"));
    language.put("sLengthMenu", messages.get("datatable.sLengthMenu"));
    language.put("sInfo", messages.get("datatable.sInfo"));
    language.put("sInfoEmpty", messages.get("datatable.sInfoEmpty"));
    language.put("sInfoFiltered", messages.get("datatable.sInfoFiltered"));
    language.put("sInfoPostFix", messages.get("datatable.sInfoPostFix"));
    language.put("sLoadingRecords", messages.get("datatable.sLoadingRecords"));
    language.put("sZeroRecords", messages.get("datatable.sZeroRecords"));
    language.put("sEmptyTable", messages.get("datatable.sEmptyTable"));
    language.put(
        "oPaginate",
        new JSONObject(
            "sFirst", messages.get("datatable.oPaginate.sFirst"),
            "sPrevious", messages.get("datatable.oPaginate.sPrevious"),
            "sNext", messages.get("datatable.oPaginate.sNext"),
            "sLast", messages.get("datatable.oPaginate.sLast")));
    language.put(
        "oAria",
        new JSONObject(
            "sSortAscending", messages.get("datatable.oAria.sSortAscending"),
            "sSortDescending", messages.get("datatable.oAria.sSortDescending")));

    return language;
  }