Ejemplo n.º 1
0
  public void addSubscriber() {
    try {
      if (program.getListEditing() == null) {
        throw new RuntimeException(
            "List is not set yet but you still manage to come to this page? Notify your admin immediately! =)");
      }

      subService.subscribe(program.getListEditingId(), this.getFieldValues());
      FacesMessenger.setFacesMessage(
          program.getFormName(), FacesMessage.SEVERITY_FATAL, "Subscriber added!", null);
      // How to redirect to List editing panel?
      program.refresh();

    } catch (EJBException ex) { // Transaction did not go through
      // Throwable cause = ex.getCause();
      FacesMessenger.setFacesMessage(
          formName, FacesMessage.SEVERITY_ERROR, "Error with transaction", ex.getMessage());
    } catch (EntityNotFoundException ex) {
      FacesMessenger.setFacesMessage(formName, FacesMessage.SEVERITY_ERROR, ex.getMessage(), "");
    } catch (IncompleteDataException ex) {
      FacesMessenger.setFacesMessage(formName, FacesMessage.SEVERITY_ERROR, ex.getMessage(), "");
    } catch (DataValidationException ex) {
      FacesMessenger.setFacesMessage(formName, FacesMessage.SEVERITY_ERROR, ex.getMessage(), "");
    } catch (RelationshipExistsException ex) {
      FacesMessenger.setFacesMessage(
          formName, FacesMessage.SEVERITY_ERROR, "Subscriber already exist in this list", "");
    } catch (Exception ex) {
      FacesMessenger.setFacesMessage(
          formName, FacesMessage.SEVERITY_ERROR, ex.getClass().getSimpleName(), ex.getMessage());
    }
  }
Ejemplo n.º 2
0
  public void initSubscriberFields() {
    long listId = program.getListEditingId();

    if (listId <= 0) {
      return;
    }
    List<SubscriptionListField> fields = program.getFieldList();
    Map<String, Object> values = subService.constructSubscriberFieldValues(fields);
    program.setFieldValues(values);
  }
Ejemplo n.º 3
0
  public void loadListFields() {
    try {
      long listId = program.getListEditingId();
      // to improve performance
      // no! it's necessary else there will be nullpointerexception :p
      if (listId <= 0) {
        return;
      }
      List<SubscriptionListField> fieldList = subService.getFieldsForSubscriptionList(listId);
      this.program.setFieldList(fieldList);

    } catch (EJBException ex) {
      FacesMessenger.setFacesMessage(
          program.getFormName(), FacesMessage.SEVERITY_ERROR, ex.getMessage(), null);
    }
  }
Ejemplo n.º 4
0
  public void loadSubscribers() {
    try {
      SubscriptionList listEditing = getListEditing();
      if (listEditing == null) return;
      // Load the maximum # of subscribers depending on the page
      // If list has 101, SUBSCRIBERS_PER_PAGE = 100 and page = 2,
      // load subscriber # (2-1)*100=100 to # (2)*100=200.
      int pageNum = getPage();
      Map<Long, Map<String, String>> accounts =
          subService.getSubscriberValuesMap(
              listEditing.getOBJECTID(), pageNum * SUBSCRIBERS_PER_PAGE, SUBSCRIBERS_PER_PAGE);

      program.setSubscriberTable(accounts);

    } catch (EJBException ex) {
      FacesMessenger.setFacesMessage(
          formName, FacesMessage.SEVERITY_ERROR, "Error with transaction", ex.getMessage());
    } catch (Exception ex) {
      FacesMessenger.setFacesMessage(
          formName, FacesMessage.SEVERITY_ERROR, ex.getClass().getSimpleName(), ex.getMessage());
    }
  }