示例#1
0
  public Item evaluateItem(XPathContext xpathContext) throws XPathException {
    if (argument.length != 1) {
      throw new XPathException("There must be 1 argument (key) for this function");
    }

    final Expression keyExpression = argument[0];
    final String key = keyExpression.evaluateAsString(xpathContext).toString();

    String value = "";
    try {
      value = de.betterform.xml.config.Config.getInstance().getProperty(key);
    } catch (XFormsConfigException e) {
    }
    return new StringValue(value);
  }
示例#2
0
  private void destroyembeddedModels(Element targetElem) throws XFormsException {
    NodeList childNodes = targetElem.getChildNodes();

    for (int index = 0; index < childNodes.getLength(); index++) {
      Node node = childNodes.item(index);

      if (node.getNodeType() == Node.ELEMENT_NODE) {
        Element elementImpl = (Element) node;

        String name = elementImpl.getLocalName();
        String uri = elementImpl.getNamespaceURI();

        if (NamespaceConstants.XFORMS_NS.equals(uri) && name.equals(XFormsConstants.MODEL)) {
          Model model = (Model) elementImpl.getUserData("");
          if (LOGGER.isDebugEnabled()) {
            LOGGER.debug("dispatch 'model-destruct' event to embedded model: " + model.getId());
            ;
          }
          String modelId = model.getId();
          // do not dispatch model-destruct to avoid problems in lifecycle
          // TODO: review: this.container.dispatch(model.getTarget(),
          // XFormsEventNames.MODEL_DESTRUCT, null);
          model.dispose();
          this.container.removeModel(model);
          model = null;
          if (Config.getInstance().getProperty("betterform.debug-allowed").equals("true")) {
            Map contextInfo = new HashMap(1);
            contextInfo.put("modelId", modelId);
            this.container.dispatch(this.target, BetterFormEventNames.MODEL_REMOVED, contextInfo);
          }

        } else {
          destroyembeddedModels(elementImpl);
        }
      }
    }
  }