Пример #1
0
  public void createNewRepeat(FormIndex index) throws InvalidReferenceException {
    TreeReference destRef = getChildInstanceRef(index);
    TreeElement template = instance.getTemplate(destRef);

    instance.copyNode(template, destRef);

    preloadInstance(instance.resolveReference(destRef));
    triggerTriggerables(destRef); // trigger conditions that depend on the creation of this new node
    initializeTriggerables(destRef); // initialize conditions for the node (and sub-nodes)
  }
Пример #2
0
  /**
   * meant to be called after deserialization and initialization of handlers
   *
   * @param newInstance true if the form is to be used for a new entry interaction, false if it is
   *     using an existing IDataModel
   */
  public void initialize(boolean newInstance) {
    if (newInstance) { // only preload new forms (we may have to revisit
      // this)
      preloadInstance(instance.getRoot());
    }

    if (getLocalizer() != null && getLocalizer().getLocale() == null) {
      getLocalizer().setToDefault();
    }

    initializeTriggerables();
  }
Пример #3
0
 /** Preload the Data Model with the preload values that are enumerated in the data bindings. */
 public void preloadInstance(TreeElement node) {
   // if (node.isLeaf()) {
   IAnswerData preload = null;
   if (node.getPreloadHandler() != null) {
     preload = preloader.getQuestionPreload(node.getPreloadHandler(), node.getPreloadParams());
   }
   if (preload != null) { // what if we want to wipe out a value in the
     // instance?
     node.setAnswer(preload);
   }
   // } else {
   if (!node.isLeaf()) {
     for (int i = 0; i < node.getNumChildren(); i++) {
       TreeElement child = node.getChildAt(i);
       if (child.getMult() != TreeReference.INDEX_TEMPLATE)
         // don't preload templates; new repeats are preloaded as they're created
         preloadInstance(child);
     }
   }
   // }
 }