Examples of TagHandler


Examples of org.apache.shindig.gadgets.templates.tags.TagHandler

  /**
   * Process conditionals and non-repeat attributes on an element
   */
  private void processElementInner(Node result, Element element) {
    TagHandler handler = registry.getHandlerFor(element);

    // An ugly special-case:  <os:Repeat> will re-evaluate the "if" attribute
    // (as it should) for each loop of the repeat.  Don't evaluate it here.
    if (!(handler instanceof RepeatTagHandler)) {
      Attr ifAttribute = element.getAttributeNode(ATTRIBUTE_IF);
      if (ifAttribute != null) {
        if (!evaluate(ifAttribute.getValue(), Boolean.class, false)) {
          return;
        }
      }
    }

    // TODO: the spec is silent on order of evaluation of "cur" relative
    // to "if" and "repeat"
    Attr curAttribute = element.getAttributeNode(ATTRIBUTE_CUR);
    Object oldCur = templateContext.getCur();
    if (curAttribute != null) {
      templateContext.setCur(evaluate(curAttribute.getValue(), Object.class, null));
    }

    if (handler != null) {
      handler.process(result, element, this);
    } else {
      // Be careful cloning nodes! If a target node belongs to a different document than the
      // template node then use importNode rather than cloneNode as that avoids side-effects
      // in UserDataHandlers where the cloned template node would belong to its original
      // document before being adopted by the target document.
View Full Code Here

Examples of org.apache.shindig.gadgets.templates.tags.TagHandler

    if (styleElement != null) {
      resources.add(TemplateResource.newStyleResource(styleElement.getTextContent(), this));
    }

    Element templateElement = (Element) DomUtil.getFirstNamedChildNode(defElement, TEMPLATE_TAG);
    TagHandler handler = createHandler(tagAttribute.getNodeValue(), templateElement,
        resources.build());
    if (handler != null) {
      handlers.add(handler);
    }
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.templates.tags.TagHandler

    Attr tagAttribute = templateElement.getAttributeNode(TAG_ATTRIBUTE);
    if (tagAttribute == null) {
      throw new TemplateParserException("Missing tag attribute on Template");
    }

    TagHandler handler = createHandler(tagAttribute.getNodeValue(), templateElement,
        ImmutableSet.<TemplateResource>of());
    if (handler != null) {
      handlers.add(handler);
    }
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.templates.tags.TagHandler

  /**
   * Process conditionals and non-repeat attributes on an element
   */
  private void processElementInner(Node result, Element element) {
    TagHandler handler = registry.getHandlerFor(element);

    // An ugly special-case:  <os:Repeat> will re-evaluate the "if" attribute
    // (as it should) for each loop of the repeat.  Don't evaluate it here.
    if (!(handler instanceof RepeatTagHandler)) {
      Attr ifAttribute = element.getAttributeNode(ATTRIBUTE_IF);
      if (ifAttribute != null) {
        if (!evaluate(ifAttribute.getValue(), Boolean.class, false)) {
          return;
        }
      }
    }

    // TODO: the spec is silent on order of evaluation of "cur" relative
    // to "if" and "repeat"
    Attr curAttribute = element.getAttributeNode(ATTRIBUTE_CUR);
    Object oldCur = templateContext.getCur();
    if (curAttribute != null) {
      templateContext.setCur(evaluate(curAttribute.getValue(), Object.class, null));
    }

    if (handler != null) {
      handler.process(result, element, this);
    } else {
      // Be careful cloning nodes! If a target node belongs to a different document than the
      // template node then use importNode rather than cloneNode as that avoids side-effects
      // in UserDataHandlers where the cloned template node would belong to its original
      // document before being adopted by the target document.
View Full Code Here

Examples of org.apache.shindig.gadgets.templates.tags.TagHandler

      public TemplateContext getTemplateContext() {
        return context;
      }
    };

    TagHandler handlerWithResources = lib.getTagRegistry()
       .getHandlerFor(new TagRegistry.NSName("#my", "Def"));
    TagHandler handlerWithNoResources = lib.getTagRegistry()
        .getHandlerFor(new TagRegistry.NSName("#my", "Flat"));

    Node result = doc.getOwnerDocument().createDocumentFragment();
    Element tag = doc.getOwnerDocument().createElement("test");

    // Script and style elements for the library should get registered
    // with the first tag for the whole library
    handlerWithNoResources.process(result, tag, processor);
    assertEquals("<STYLE>libstyle\nlibstyle2</STYLE>" +
                 "<JAVASCRIPT>libscript\nlibscript2</JAVASCRIPT>",
                 serializeResources(context));

    // Now script and style elements for the tag should get registered
View Full Code Here

Examples of org.apache.shindig.gadgets.templates.tags.TagHandler

    if (styleElement != null) {
      resources.add(TemplateResource.newStyleResource(styleElement.getTextContent(), this));
    }

    Element templateElement = (Element) DomUtil.getFirstNamedChildNode(defElement, TEMPLATE_TAG);
    TagHandler handler = createHandler(tagAttribute.getNodeValue(), templateElement,
        resources.build());
    if (handler != null) {
      handlers.add(handler);
    }
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.templates.tags.TagHandler

    Attr tagAttribute = templateElement.getAttributeNode(TAG_ATTRIBUTE);
    if (tagAttribute == null) {
      throw new TemplateParserException("Missing tag attribute on Template");
    }
   
    TagHandler handler = createHandler(tagAttribute.getNodeValue(), templateElement,
        ImmutableSet.<TemplateResource>of());
    if (handler != null) {
      handlers.add(handler);
    }
  }
View Full Code Here

Examples of org.apache.shindig.gadgets.templates.tags.TagHandler

 
  /**
   * Process conditionals and non-repeat attributes on an element
   */
  private void processElementInner(Node result, Element element) {
    TagHandler handler = registry.getHandlerFor(element);
   
    // An ugly special-case:  <os:Repeat> will re-evaluate the "if" attribute
    // (as it should) for each loop of the repeat.  Don't evaluate it here.
    if (!(handler instanceof RepeatTagHandler)) {
      Attr ifAttribute = element.getAttributeNode(ATTRIBUTE_IF);
      if (ifAttribute != null) {
        if (!evaluate(ifAttribute.getValue(), Boolean.class, false)) {
          return;
        }
      }
    }

    // TODO: the spec is silent on order of evaluation of "cur" relative
    // to "if" and "repeat"
    Attr curAttribute = element.getAttributeNode(ATTRIBUTE_CUR);
    Object oldCur = templateContext.getCur();
    if (curAttribute != null) {
      templateContext.setCur(evaluate(curAttribute.getValue(), Object.class, null));
    }
   
    if (handler != null) {
      handler.process(result, element, this);
    } else {
      // Be careful cloning nodes! If a target node belongs to a different document than the
      // template node then use importNode rather than cloneNode as that avoids side-effects
      // in UserDataHandlers where the cloned template node would belong to its original
      // document before being adopted by the target document.
View Full Code Here

Examples of org.openmrs.module.htmlformentry.handler.TagHandler

    private void applyTagsHelper(FormEntrySession session, PrintWriter out, Node parent, Node node,
                                 Map<String, TagHandler> tagHandlerCache) {
        if (tagHandlerCache == null)
            tagHandlerCache = new HashMap<String, TagHandler>();
        TagHandler handler = null;
        // Find the handler for this node
        {
            String name = node.getNodeName();
            if (name != null) {
                if (tagHandlerCache.containsKey(name)) {
                    // we've looked this up before (though it could be null)
                    handler = tagHandlerCache.get(name);
                } else {
                    handler = HtmlFormEntryUtil.getService().getHandlerByTagName(name);
                    tagHandlerCache.put(name, handler);
                }
            }
        }

        if (handler == null)
            handler = this; // do default actions

        try {
            boolean handleContents = handler.doStartTag(session, out, parent, node);

            // Unless the handler told us to skip them, then iterate over any children
            if (handleContents) {
                if (handler != null && handler instanceof IteratingTagHandler) {
                    // recurse as many times as the tag wants
                    IteratingTagHandler iteratingHandler = (IteratingTagHandler) handler;
                    while (iteratingHandler.shouldRunAgain(session, out, parent, node)) {
                        NodeList list = node.getChildNodes();
                        for (int i = 0; i < list.getLength(); ++i) {
                            applyTagsHelper(session, out, node, list.item(i), tagHandlerCache);
                        }
                    }

                } else { // recurse to contents once
                    NodeList list = node.getChildNodes();
                    for (int i = 0; i < list.getLength(); ++i) {
                        applyTagsHelper(session, out, node, list.item(i), tagHandlerCache);
                    }
                }
            }

            handler.doEndTag(session, out, parent, node);
        } catch (BadFormDesignException e) {
            out.print("<div class=\"error\">" + handler + " reported an error in the design of the form. Consult your administrator.<br/><pre>");
            e.printStackTrace(out);
            out.print("</pre></div>");
        }
View Full Code Here

Examples of speculoos.config.xml.TagHandler

   *
   */
  public JNDIXMLConfigurator() {
    PropertyHandler ph = new PropertyHandler();
    // for backward compatibility of descriptors
    handlers.put("jndi-mapper", new TagHandler() {

      public void endElement(String uri, String localName, String qName)
          throws SAXException {
        // NOP
      }

      public void startElement(String uri, String localName,
          String qName, Attributes attributes) throws SAXException {
        // NOP
      }

    });
    handlers.put("map", new MapHandler());
    handlers.put("attr", ph);
    handlers.put("bean", new BeanHandler());
    handlers.put("source", new SourceHandler());
    handlers.put("config", new ConfigHandler());
    handlers.put("property", ph);
    // validation rules
    handlers.put("and", new AndValidHandler());
    handlers.put("or", new OrValidHandler());
    handlers.put("not", new NotValidHandler());
    handlers.put("regex", new RegexValidHandler());
    handlers.put("defaults", new DefaultsValidHandler());
    handlers.put("mandatory", new MandatoryValidHandler());
    // chains
    ChainHandler ch = new ChainHandler();
    handlers.put("chain", ch);
    // basic
    handlers.put("root", new RootHandler());
    // modify
    handlers.put("modify", new ModifyHandler());
    handlers.put("operations", new TagHandler() {

      public void endElement(String uri, String localName, String qName)
          throws SAXException {
        ModificationsVariables mods = (ModificationsVariables) pop();
        ((JNDIMapper) current).getInputChain().addMapper(mods);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.