コード例 #1
0
ファイル: FormDef.java プロジェクト: ClaudiaAlawi/MyRepo
  public void setInstance(FormInstance instance) {
    if (instance.getFormId() != -1 && getID() != instance.getFormId()) {
      System.err.println(
          "Warning: assigning incompatible instance (type "
              + instance.getFormId()
              + ") to a formdef (type "
              + getID()
              + ")");
    }

    instance.setFormId(getID());
    this.instance = instance;
    attachControlsToInstanceData();
  }
コード例 #2
0
ファイル: FormDef.java プロジェクト: ClaudiaAlawi/MyRepo
  private void attachControlsToInstanceData(TreeElement node) {
    for (int i = 0; i < node.getNumChildren(); i++) {
      attachControlsToInstanceData(node.getChildAt(i));
    }

    IAnswerData val = node.getValue();
    Vector selections = null;
    if (val instanceof SelectOneData) {
      selections = new Vector();
      selections.addElement(val.getValue());
    } else if (val instanceof SelectMultiData) {
      selections = (Vector) val.getValue();
    }

    if (selections != null) {
      QuestionDef q = findQuestionByRef(node.getRef(), this);
      if (q == null) {
        throw new RuntimeException(
            "FormDef.attachControlsToInstanceData: can't find question to link");
      }

      if (q.getDynamicChoices() != null) {
        // droos: i think we should do something like initializing the itemset here, so that default
        // answers
        // can be linked to the selectchoices. however, there are complications. for example, the
        // itemset might
        // not be ready to be evaluated at form initialization; it may require certain questions to
        // be answered
        // first. e.g., if we evaluate an itemset and it has no choices, the xform engine will throw
        // an error
        // itemset TODO
      }

      for (int i = 0; i < selections.size(); i++) {
        Selection s = (Selection) selections.elementAt(i);
        s.attachChoice(q);
      }
    }
  }
コード例 #3
0
ファイル: FormDef.java プロジェクト: ClaudiaAlawi/MyRepo
 /**
  * Link a deserialized instance back up with its parent FormDef. this allows select/select1
  * questions to be internationalizable in chatterbox, and (if using CHOICE_INDEX mode) allows the
  * instance to be serialized to xml
  */
 public void attachControlsToInstanceData() {
   attachControlsToInstanceData(instance.getRoot());
 }