예제 #1
0
  @Override
  public Widget initialize() {

    container = new SquarePanel(true);
    container.setVisible(false);

    // Create form and sets labels
    form = new FormField();

    userId = getParameters().getRequiredLong(ParameterKey.ID);

    // Display contact information
    getUserData();

    container.add(form);

    return container;
  }
예제 #2
0
  /** Renders form data */
  private void renderUserData() {

    Member member = userData.getMember();
    JsArray<CustomFieldValue> customFieldValues = null;

    Map<String, String> formData = new LinkedHashMap<String, String>();

    // Add member properties
    if (member != null) {
      formData.put(messages.username(), member.getUsername());
      formData.put(messages.name(), member.getName());
      formData.put(messages.email(), new EmailField(member.getEmail()).getHTML());
      customFieldValues = member.getCustomValues();
    }

    // Add custom fields
    if (customFieldValues != null && customFieldValues.length() > 0) {
      for (int i = 0; i < customFieldValues.length(); i++) {
        CustomFieldValue value = customFieldValues.get(i);
        formData.put(value.getDisplayName(), value.getValue());
      }
    }

    form.setData(formData);

    List<PageAction> actions = null;

    // Check if is not the logged user because himself cannot be added as contact and cannot make a
    // payment to himself
    if (!LoggedUser.get().getUserId().equals(userId)) {
      actions = new ArrayList<PageAction>();
      // Add contact action if related member is not a contact yet
      if (userData.isCanAddMemberAsContact()) {
        actions.add(getAddToContactsAction());
      }
      if (LoggedUser.get().getInitialData().canMakeMemberPayments()) {
        actions.add(getMakePaymentAction());
      }
    }

    // Add actions asynchronously
    CyclosMobile.get().getMainLayout().addActions(actions, true);

    // Display loaded data
    container.setVisible(true);
  }