Package org.thymeleaf.dom

Examples of org.thymeleaf.dom.Element


      }

      String result = myProfileTemplateEngine.process(name, context);
      Document dom = DOMUtils.getXhtmlDOMFor(new StringReader(result));

      Element firstChild = (Element) dom.getFirstChild();
      for (Node next : firstChild.getChildren()) {
        theElement.addChild(next);
      }

      return ProcessorResult.ok();
    }
View Full Code Here


  @Override
  public boolean matchesSafely(HtmlElement item) {
    StringBuilder text = new StringBuilder();
    boolean fail = false;
   
    Element element = item.getElement();
    if(element!=null && element.hasChildren()) {
      List<Node> children = element.getChildren();
   
      for(Node child : children) {
        if(child instanceof Text) {
          text.append(((Text)child).getContent());
        } else if(!(child instanceof Comment)) {
View Full Code Here

        StringBuilder text = new StringBuilder();
        boolean fail = true;
        boolean elementFound = false;
        boolean textFound = false;

        Element element = item.getElement();
        if(element!=null && element.hasChildren()) {
            List<Node> children = element.getChildren();

            for(Node child : children) {
                if(child instanceof Text) {
                    text.append(((Text)child).getContent());
                    if (textFound) {
View Full Code Here

    } else {
      Document doc = parser.parseTemplate(this.getConfiguration(), path, new StringReader(htmlString));
      nodes = doc.getChildren();
    }

    Element root = new Element("#document");
    root.setChildren(nodes);

    return new HtmlElements(root);
  }
View Full Code Here

    }
  }

  @Override
  protected boolean matchesSafely(HtmlElement item) {   
    Element element = item.getElement();
    if(element!=null && element.hasChildren()) {
      List<Node> children = element.getChildren();
   
      for(Node child : children) {
        if(child instanceof Comment) {
          if(expectedText==null) {
            return true;
View Full Code Here

    expectedClassNames = toSet(className);
  }
 
  @Override
  public boolean matchesSafely(HtmlElement item) {
    Element element = item.getElement();
    String classes = element.getAttributeValue("class");
    Set<String> classNames = toSet(classes);

    return classNames.containsAll(expectedClassNames);
  }
View Full Code Here

  }

  @Override
  protected ProcessorResult doProcess(Arguments arguments, ProcessorMatchingContext processorMatchingContext, Node node) {

    Element element = ((Element) node);
    Map<String, Attribute> attributeMap = element.getAttributeMap();
    String dialectPrefix = processorMatchingContext.getDialectPrefix();

    Configuration configuration = arguments.getConfiguration();
    final IStandardExpressionParser expressionParser = StandardExpressions.getExpressionParser(configuration);

    final Map<String, Object> newLocalVariables = new HashMap<String, Object>(1, 1.0f);

    Arguments withExecutionArguments = arguments;

    for (Attribute attribute : attributeMap.values()) {
      if (dialectPrefix.equals(Attribute.getPrefixFromAttributeName(attribute.getNormalizedName()))) {
        final String newVariableName = Attribute.getUnprefixedAttributeName(attribute.getOriginalName());
        final IStandardExpression expression = expressionParser.parseExpression(arguments.getConfiguration(),
            withExecutionArguments, attribute.getValue());
        final Object newVariableValue = expression.execute(configuration, withExecutionArguments);
        withExecutionArguments = withExecutionArguments.addLocalVariables(Collections.singletonMap(newVariableName,
            newVariableValue));
        newLocalVariables.put(newVariableName, newVariableValue);
        element.removeAttribute(attribute.getNormalizedName());
      }
    }
    return ProcessorResult.setLocalVariables(newLocalVariables);
  }
View Full Code Here

      String result = myProfileTemplateEngine.process(name, context);
      String trim = result.trim();
      Document dom = getXhtmlDOMFor(new StringReader(trim));

      Element firstChild = (Element) dom.getFirstChild();
      for (int i = 0; i < firstChild.getChildren().size(); i++) {
        Node next = firstChild.getChildren().get(i);
        if (i == 0 && firstChild.getChildren().size() == 1) {
          if (next instanceof org.thymeleaf.dom.Text) {
            org.thymeleaf.dom.Text nextText = (org.thymeleaf.dom.Text) next;
            nextText.setContent(nextText.getContent().trim());
          }
        }
View Full Code Here

     *     </div>
     * }
     * </pre>
     */
    private void addTabAnchors(Arguments arguments, Element tabContainer, String tabContainerId) {
        Element ul = new Element("ul");
        for (Element child : tabContainer.getElementChildren()) {
            if ("div".equals(child.getOriginalName())) {
                Element div = (Element) child;
                // Get tab title and id
                String tabTitle = getTitle(arguments, div);
                String tabId = DomUtils.getOrCreateId(arguments.getDocument(), div, "tab-");
                // Build li element
                Element li = new Element("li");
                Element a = new Element("a");
                a.setAttribute("href", "#" + tabId);
                a.addChild(new Text(tabTitle));
                li.addChild(a);
                ul.addChild(li);
                // Add next event
                addNextTab(div, tabContainerId);
            }
View Full Code Here

     */
    private void addNextTab(Element element, String tabId) {
        // FIXME: remove input hidden ocurrences
        List<Element> formElements = DomUtils.getElementsByTagNames(element, "input", "select", "textarea");
        if (!formElements.isEmpty()) {
            Element lastElement = formElements.get(formElements.size() - 1);
            String value = "nextTab(event, '" + tabId + "')";
            if (notEmpty(lastElement.getAttributeValue("onkeypress"))) {
                value += "; " + lastElement.getAttributeValue("onkeypress");
            }
            lastElement.setAttribute("onkeypress", value);
        }
    }
View Full Code Here

TOP

Related Classes of org.thymeleaf.dom.Element

Copyright © 2018 www.massapicom. 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.