Package org.thymeleaf.dom

Examples of org.thymeleaf.dom.Element


        }

        // Host node is NOT to be removed, therefore what should be removed is the top-level elements of the returned
        // nodes.

        final Element containerElement = new Element("container");

        for (final Node extractedNode : extractedNodes) {
            // This is done in this indirect way in order to preserver internal structures like e.g. local variables.
            containerElement.addChild(extractedNode);
            containerElement.extractChild(extractedNode);
        }

        final List<Node> extractedChildren = containerElement.getChildren();
        containerElement.clearChildren();

        return extractedChildren;

    }
View Full Code Here


      element.clearChildren();
      element.getParent().insertAfter(element, contents.get(0));
      element.getParent().removeChild(element);
    } else {
      log.debug("Cache not found. Adding add processor element.");
      Element cacheDiv = new Element("div");
      cacheDiv.setAttribute("cache:add", cacheName);
      element.addChild(cacheDiv);
    }
    return ProcessorResult.OK;
  }
View Full Code Here

                    String action = (String) expression.execute(arguments.getConfiguration(), arguments);
                    String csrfQueryParameter = "?" + eps.getCsrfTokenParameter() + "=" + csrfToken;
                    element.removeAttribute("th:action");
                    element.setAttribute("action", action + csrfQueryParameter);
                } else {
                    Element csrfNode = new Element("input");
                    csrfNode.setAttribute("type", "hidden");
                    csrfNode.setAttribute("name", eps.getCsrfTokenParameter());
                    csrfNode.setAttribute("value", csrfToken);
                    element.addChild(csrfNode);
                }

            } catch (ServiceException e) {
                throw new RuntimeException("Could not get a CSRF token for this session", e);
            }
        }
       
        // Convert the <blc:form> node to a normal <form> node
        Element newElement = element.cloneElementNodeWithNewName(element.getParent(), "form", false);
        newElement.setRecomputeProcessorsImmediately(true);
        element.getParent().insertAfter(element, newElement);
        element.getParent().removeChild(element);
       
        return ProcessorResult.OK;
    }
View Full Code Here

        //Append any hidden fields necessary for the Transparent Redirect
        Map<String, String> hiddenFields = formParameters.get(formHiddenParamsKey.toString());
        if (hiddenFields != null && !hiddenFields.isEmpty()) {
            for (String key : hiddenFields.keySet()) {
                Element hiddenNode = new Element("input");
                hiddenNode.setAttribute("type", "hidden");
                hiddenNode.setAttribute("name", key);
                hiddenNode.setAttribute("value", hiddenFields.get(key));
                element.addChild(hiddenNode);
            }
        }

        // Convert the <blc:transparent_credit_card_form> node to a normal <form> node
        Element newElement = element.cloneElementNodeWithNewName(element.getParent(), "form", false);
        newElement.setRecomputeProcessorsImmediately(true);
        element.getParent().insertAfter(element, newElement);
        element.getParent().removeChild(element);

        return ProcessorResult.OK;
    }
View Full Code Here

        for (String a : attributeNames) {
            String attrName = a.toLowerCase();
            if (attrName.startsWith("th")) {
                if (attrName.equals("th:substituteby") || (attrName.equals("th:replace") || attrName.equals("th:include"))) {
                    if (!elementAdded) {
                        Element extraDiv = new Element("div");
                        String attrValue = element.getAttributeValue(attrName);
                        element.removeAttribute(attrName);
                        extraDiv.setAttribute(attrName, attrValue);
                        element.addChild(extraDiv);
                        elementAdded = true;
                        element.setNodeProperty("templateName", attrValue);

                        // This will ensure that the substituteby and replace processors only run for the child element
View Full Code Here

                }
            }
            Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration())
                    .parseExpression(arguments.getConfiguration(), arguments, "@{'" + mappingPrefix + versionedBundle + "'}");
            String value = (String) expression.execute(arguments.getConfiguration(), arguments);
            Element e = getElement(value);
            parent.insertAfter(element, e);
        } else {
            List<String> additionalBundleFiles = bundlingService.getAdditionalBundleFiles(name);
            if (additionalBundleFiles != null) {
                files.addAll(additionalBundleFiles);
            }
            for (String file : files) {
                file = file.trim();
                Expression expression = (Expression) StandardExpressions.getExpressionParser(arguments.getConfiguration())
                        .parseExpression(arguments.getConfiguration(), arguments, "@{'" + mappingPrefix + file + "'}");
                String value = (String) expression.execute(arguments.getConfiguration(), arguments);
                Element e = getElement(value);
                parent.insertBefore(element, e);
            }
        }
       
        parent.removeChild(element);
View Full Code Here

        parent.removeChild(element);
        return ProcessorResult.OK;
    }
   
    protected Element getScriptElement(String src) {
        Element e = new Element("script");
        e.setAttribute("type", "text/javascript");
        e.setAttribute("src", src);
        return e;
    }
View Full Code Here

        e.setAttribute("src", src);
        return e;
    }
   
    protected Element getLinkElement(String src) {
        Element e = new Element("link");
        e.setAttribute("rel", "stylesheet");
        e.setAttribute("href", src);
        return e;
    }
View Full Code Here

    DOMNodeSelector selector = new DOMNodeSelector(document);
    Set<Node> matches = selector.querySelectorAll(selectorText);
    for(Node matchedNode : matches) {
      if(matchedNode instanceof Element) {
        Element element = (Element)matchedNode;
            for (Map.Entry<String,String> rule : styles.entrySet()) {
              element.setAttribute(rule.getKey(), rule.getValue());
            }
      }
    }
  }
View Full Code Here

 
  protected void handleRule(ElementRule elementRule, Set<Node> matches) throws NodeSelectorException {
   
    for(Node matchedNode : matches) {
      if(matchedNode instanceof Element) {
        Element element = (Element)matchedNode;
        elementRule.applyTo(element);
      }
    }
  }
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.