コード例 #1
0
ファイル: PrismValuePanel.java プロジェクト: mythoss/midpoint
  private Panel createInputComponent(String id, IModel<String> labelModel, Form form) {
    ValueWrapper valueWrapper = valueWrapperModel.getObject();
    ObjectWrapper objectWrapper = null;
    if (valueWrapper.getItem().getContainer() != null) {
      objectWrapper = valueWrapper.getItem().getContainer().getObject();
    }
    Item property = valueWrapper.getItem().getItem();
    boolean required = property.getDefinition().getMinOccurs() > 0;

    Panel component = createTypedInputComponent(id);

    if (component instanceof InputPanel) {
      InputPanel inputPanel = (InputPanel) component;
      // adding valid from/to date range validator, if necessary
      ItemPath activation = new ItemPath(UserType.F_ACTIVATION);
      if (ActivationType.F_VALID_FROM.equals(property.getElementName())) {
        DateValidator validator = getActivationRangeValidator(form, activation);
        validator.setDateFrom((DateTimeField) inputPanel.getBaseFormComponent());
      } else if (ActivationType.F_VALID_TO.equals(property.getElementName())) {
        DateValidator validator = getActivationRangeValidator(form, activation);
        validator.setDateTo((DateTimeField) inputPanel.getBaseFormComponent());
      }

      final List<FormComponent> formComponents = inputPanel.getFormComponents();
      for (FormComponent formComponent : formComponents) {
        formComponent.setLabel(labelModel);
        formComponent.setRequired(required);

        if (formComponent instanceof TextField) {
          formComponent.add(new AttributeModifier("size", "42"));
        }
        formComponent.add(
            new AjaxFormComponentUpdatingBehavior("blur") {

              @Override
              protected void onUpdate(AjaxRequestTarget target) {}
            });

        // Validation occurs when submitting the form
        //            if (form != null) {
        //                AjaxFormValidatingBehavior validator = new
        // AjaxFormValidatingBehavior(form, "Blur");
        //
        //                formComponent.add(validator);
        //            }
      }
    }
    if (component == null) {
      throw new RuntimeException(
          "Cannot create input component for item "
              + property
              + " ("
              + valueWrapper
              + ") in "
              + objectWrapper);
    }
    return component;
  }
コード例 #2
0
ファイル: PrismValuePanel.java プロジェクト: mythoss/midpoint
 private boolean isUserOrgItem(Item item, Class referenceType) {
   return (referenceType == ObjectType.class || referenceType == FocusType.class)
       && (AbstractRoleType.F_APPROVER_REF.equals(item.getElementName())
           || AbstractRoleType.F_OWNER_REF.equals(item.getElementName()));
 }