コード例 #1
0
ファイル: QuestionField.java プロジェクト: JishamSaju/kc
  @Override
  public void performApplyModel(Object model, LifecycleElement parent) {
    Object myBo =
        ObjectPropertyUtils.getPropertyValue(
            model, KcBindingInfo.getParentBindingInfo(getBindingInfo()));
    Answer answer = (Answer) myBo;
    setControl(
        (Control)
            ComponentFactory.getNewComponentInstance(
                getControlMappings().get(answer.getQuestion().getQuestionTypeId().toString())));
    getControl().getCssClasses().add("answer");
    if (StringUtils.isNotBlank(answer.getQuestion().getLookupClass())) {
      if (useSuggest) {
        getSuggest().setRender(true);
        getSuggest().setValuePropertyName(answer.getQuestion().getLookupReturn());
        getSuggest()
            .getSuggestQuery()
            .setDataObjectClassName(answer.getQuestion().getLookupClass());
      }

      getQuickfinder().setRender(true);
      getQuickfinder().setDataObjectClassName(answer.getQuestion().getLookupClass());
      getQuickfinder()
          .getFieldConversions()
          .put(answer.getQuestion().getLookupReturn(), getPropertyName());
    }
    super.performApplyModel(model, parent);
  }
コード例 #2
0
  /**
   * If control definition is defined on the given attribute definition, converts to an appropriate
   * control for searching (if necessary) and returns a copy for setting on the field.
   *
   * @param attributeDefinition attribute definition instance to retrieve control from
   * @return Control instance or null if not found
   */
  protected static Control convertControlToLookupControl(AttributeDefinition attributeDefinition) {
    if (attributeDefinition.getControlField() == null) {
      return null;
    }

    Control newControl = null;

    // convert checkbox to radio with yes/no/both options
    if (CheckboxControl.class.isAssignableFrom(attributeDefinition.getControlField().getClass())) {
      newControl =
          (RadioGroupControl)
              ComponentFactory.getNewComponentInstance(
                  ComponentFactory.CHECKBOX_CONVERTED_RADIO_CONTROL);
    }
    // text areas get converted to simple text inputs
    else if (TextAreaControl.class.isAssignableFrom(
        attributeDefinition.getControlField().getClass())) {
      newControl = ComponentFactory.getTextControl();
    } else {
      newControl = ComponentUtils.copy(attributeDefinition.getControlField(), "");
    }

    return newControl;
  }