コード例 #1
0
  @Override
  public void outputAjaxDiff(
      PipelineContext pipelineContext,
      ContentHandlerHelper ch,
      XFormsControl other,
      AttributesImpl attributesImpl,
      boolean isNewlyVisibleSubtree) {
    // Output regular diff
    super.outputAjaxDiff(pipelineContext, ch, other, attributesImpl, isNewlyVisibleSubtree);

    // Output itemset diff
    if (mustSendItemsetUpdate(pipelineContext, (XFormsSelect1Control) other)) {
      ch.startElement(
          "xxf",
          XFormsConstants.XXFORMS_NAMESPACE_URI,
          "itemset",
          new String[] {"id", XFormsUtils.namespaceId(containingDocument, getEffectiveId())});
      {
        final Itemset itemset = getItemset(pipelineContext);
        if (itemset != null) {
          final String result =
              itemset.getJSONTreeInfo(pipelineContext, null, false, getLocationData());
          if (result.length() > 0) ch.text(result);
        }
      }
      ch.endElement();
    }
  }
コード例 #2
0
  @Override
  public void outputAjaxDiff(
      ContentHandlerHelper ch,
      XFormsControl other,
      AttributesImpl attributesImpl,
      boolean isNewlyVisibleSubtree) {
    // Output regular diff
    super.outputAjaxDiff(ch, other, attributesImpl, isNewlyVisibleSubtree);

    // Output switch-specific diff if needed only
    final XFormsSwitchControl otherSwitchControl = (XFormsSwitchControl) other;
    if (!compareSelectedCase(otherSwitchControl)) {

      if (isRelevant()) {

        // Output newly selected case id
        final String selectedCaseEffectiveId = getSelectedCaseEffectiveId();
        assert selectedCaseEffectiveId != null;
        ch.element(
            "xxf",
            XFormsConstants.XXFORMS_NAMESPACE_URI,
            "div",
            new String[] {
              "id",
              XFormsUtils.namespaceId(containingDocument(), selectedCaseEffectiveId),
              "visibility",
              "visible"
            });

        if (otherSwitchControl != null && otherSwitchControl.isRelevant()) {
          // Used to be relevant, simply output deselected case ids
          final String previousSelectedCaseId = getOtherSelectedCaseEffectiveId(otherSwitchControl);
          assert previousSelectedCaseId != null;
          ch.element(
              "xxf",
              XFormsConstants.XXFORMS_NAMESPACE_URI,
              "div",
              new String[] {
                "id",
                XFormsUtils.namespaceId(containingDocument(), previousSelectedCaseId),
                "visibility",
                "hidden"
              });
        } else {
          // Control was not relevant, send all deselected to be sure
          // TODO: This should not be needed because the repeat template should have a reasonable
          // default.
          final List<XFormsCaseControl> children = getChildrenCases();
          if (children != null && children.size() > 0) {
            for (final XFormsCaseControl caseControl : children) {
              if (!caseControl.getEffectiveId().equals(selectedCaseEffectiveId)) {
                ch.element(
                    "xxf",
                    XFormsConstants.XXFORMS_NAMESPACE_URI,
                    "div",
                    new String[] {
                      "id",
                      XFormsUtils.namespaceId(containingDocument(), caseControl.getEffectiveId()),
                      "visibility",
                      "hidden"
                    });
              }
            }
          }
        }
      }
    }
  }