Package org.thymeleaf.dom

Examples of org.thymeleaf.dom.Element


      logger.debug("No configuration to apply, i.e. no '" + DataTablesDialect.DIALECT_PREFIX
          + ":conf' has been found in the current template.");
    }
   
    // The config node (the one with the dt:conf attribute), if it exists
    Element configNode = (Element) RequestUtils.getFromRequest(DataTablesDialect.INTERNAL_NODE_CONFIG, request);
    if (configNode != null) {
      configNode.getParent().removeChild(configNode);
    }
  }
View Full Code Here


   *            The {@link HtmlTable} which the CSS configuration will apply
   *            on.
   */
  private void applyCssConfiguration(Arguments arguments, HttpServletRequest request, HtmlTable htmlTable) {

    Element tableElement = (Element) RequestUtils.getFromRequest(DataTablesDialect.INTERNAL_NODE_TABLE, request);

    // CSS class
    StringBuilder configuredCssClass = TableConfig.CSS_CLASS.valueFrom(htmlTable.getTableConfiguration());
    if (configuredCssClass != null) {

      String currentCssClass = tableElement.getAttributeValue("class");
      if (StringUtils.isNotBlank(currentCssClass)) {
        currentCssClass += HtmlTag.CLASS_SEPARATOR + configuredCssClass.toString();
      }
      else {
        currentCssClass = configuredCssClass.toString();
      }
      tableElement.setAttribute("class", currentCssClass);
    }

    // CSS style
    StringBuilder configuredCssStyle = TableConfig.CSS_STYLE.valueFrom(htmlTable.getTableConfiguration());
    if (configuredCssStyle != null) {

      String currentCssStyle = tableElement.getAttributeValue("style");
      if (StringUtils.isNotBlank(currentCssStyle)) {
        currentCssStyle += HtmlTag.STYLE_SEPARATOR + configuredCssStyle.toString();
      }
      else {
        currentCssStyle = configuredCssStyle.toString();
      }
      tableElement.setAttribute("style", currentCssStyle);
    }
  }
View Full Code Here

        if (extraHtmls != null && !extraHtmls.isEmpty()) {

          for (ExtraHtml extraHtml : extraHtmls) {
            if (extraHtml.getUid().equals(uid)) {

              Element e = DomUtils.findElement((Element) element.getParent(), "div",
                  DataTablesDialect.DIALECT_PREFIX + ":uid", uid);

              StringBuilder sb = new StringBuilder();
              for (Node child : e.getChildren()) {
                sb.append(DOMUtils.getHtml5For(child).replaceAll("[\n\r]", "").trim());
              }

              extraHtml.setContent(sb.toString());
            }
View Full Code Here

    // All the tbody tag are iterated over
    for (Node child : element.getChildren()) {

      if (child != null && child instanceof Element) {

        Element trChildTag = (Element) child;
        String trChildTagName = trChildTag.getNormalizedName();

        // The tr nodes must be processed (for HtmlRow creation)
        trChildTag.setProcessable(true);

        if (trChildTagName != null && trChildTagName.equals("tr")) {

          for (Node grandchild : trChildTag.getChildren()) {

            if (grandchild != null && grandchild instanceof Element) {

              Element thChildTag = (Element) grandchild;
              thChildTag.setAttribute(DataTablesDialect.DIALECT_PREFIX + ":data", "internalUse");

              // The td nodes must be processed too (for
              // HtmlColumn creation)
              thChildTag.setProcessable(true);
            }
          }
        }
      }
    }
View Full Code Here

    // All the tbody tag are iterated over
    for (Node trChild : element.getChildren()) {

      if (trChild != null && trChild instanceof Element) {

        Element trChildTag = (Element) trChild;
        String trChildTagName = trChildTag.getNormalizedName();

        // The tr nodes must be processed (for HtmlRow creation)
        trChildTag.setProcessable(true);

        if (trChildTagName != null && trChildTagName.equals("tr")) {

          if (trChildTag.hasAttribute("th:each")) {

            trChildTag.setAttribute(DataTablesDialect.DIALECT_PREFIX + ":data", "internalUse");

            for (Node grandchild : trChildTag.getChildren()) {

              if (grandchild != null && grandchild instanceof Element) {

                Element tdChildTag = (Element) grandchild;
                tdChildTag.setAttribute(DataTablesDialect.DIALECT_PREFIX + ":data", "internalUse");

                // The td nodes must be processed too (for
                // HtmlColumn creation)
                tdChildTag.setProcessable(true);
              }
            }
          }
        }
      }
View Full Code Here

    // Markers on THEAD and TBODY tags
    for (Node child : element.getChildren()) {

      if (child != null && child instanceof Element) {

        Element childTag = (Element) child;
        String childTagName = childTag.getNormalizedName();

        if (childTagName.equals("thead") || childTagName.equals("tbody")) {
          childTag.setAttribute(DataTablesDialect.DIALECT_PREFIX + ":data", "internalUse");
        }
       
        childTag.setProcessable(true);
      }
    }
   
    // "Finalizing div"
    Element div = new Element("div");
    div.setAttribute(DataTablesDialect.DIALECT_PREFIX + ":tmp", "internalUse");
    div.setRecomputeProcessorsImmediately(true);
    element.getParent().insertAfter(element, div);
  }
View Full Code Here

    if (element.getOriginalName().equals(elementName)) {
      return element;
    }
    for (Element child : element.getElementChildren()) {
      Element result = findElement(child, elementName);
      if (result != null) {
        return result;
      }
    }
    return null;
View Full Code Here

    if (element.getOriginalName().equals(elementName) && element.hasAttribute(attributeName)
        && element.getAttributeValue(attributeName).equals(attributeValue)) {
      return element;
    }
    for (Element child : element.getElementChildren()) {
      Element result = findElement(child, elementName, attributeName, attributeValue);
      if (result != null) {
        return result;
      }
    }
    return null;
View Full Code Here

 
  @Override
  protected void adaptHeader(HtmlTable table) {
   
    Node tableNode = (Node) ((IWebContext) arguments.getContext()).getHttpServletRequest().getAttribute(DataTablesDialect.INTERNAL_NODE_TABLE);
    Element thead = DomUtils.findElement((Element) tableNode, "thead");
   
    Element tr = new Element("tr");
    for(HtmlColumn column : table.getLastHeaderRow().getColumns()){
      Element th = new Element("th");
      th.addChild(new Text(column.getContent().toString()));
      tr.addChild(th);
    }

    if(thead != null){
      thead.addChild(tr);
    }
    else{
      thead = new Element("thead");
      thead.addChild(tr);
      ((Element) tableNode).addChild(thead);
    }
   
  }
View Full Code Here

  }

  @Override
  protected void adaptFooter(HtmlTable table) {
   
    Element tfoot = new Element("tfoot");

    Node tableNode = (Node) ((IWebContext) arguments.getContext()).getHttpServletRequest().getAttribute(DataTablesDialect.INTERNAL_NODE_TABLE);
   
    for(HtmlColumn column : table.getLastHeaderRow().getColumns()){
      Element th = new Element("th");
      th.addChild(new Text(column.getContent().toString()));
      tfoot.addChild(th);
    }

    ((Element) tableNode).addChild(tfoot);
  }
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.