Package com.github.dandelion.datatables.core.html

Examples of com.github.dandelion.datatables.core.html.ExtraHtml


    TableTag parent = (TableTag) findAncestorWithClass(this, TableTag.class);

    // The tag is evaluated only once, at the first iteration
    if (parent.isFirstIteration()) {
     
      ExtraHtml extraHtml = new ExtraHtml();
      extraHtml.setUid(uid);
      extraHtml.setContainer(StringUtils.isNotBlank(container) ? StringUtils.escape(this.escapeXml,
          this.container) : "div");
      extraHtml.setCssStyle(cssStyle);
      extraHtml.setCssClass(cssClass);
      if (getBodyContent() != null) {
        extraHtml.setContent(getBodyContent().getString().replaceAll("[\n\r]", "").trim());
      }
     
      parent.getTable().getTableConfiguration().addExtraHtmlSnippet(extraHtml);
      parent.getTable().getTableConfiguration().registerExtension(new ExtraHtmlFeature());
    }
View Full Code Here


  }
 
  @Test
  public void should_add_an_extraHtml_with_processed_content() throws JspException, UnsupportedEncodingException {
   
    ExtraHtml extraHtml = new ExtraHtml();
    extraHtml.setContent("<a href=\"http://myDomain.com\">Link</a><div>Content</div>");
    extraHtml.setUid("M");
    extraHtml.setCssClass("class1");
    extraHtml.setCssStyle("float:left");
    extraHtml.setContainer("div");
   
    assertThat(table.getTableConfiguration().getExtraHtmlSnippets()).hasSize(1);
    assertThat(table.getTableConfiguration().getExtraHtmlSnippets()).contains(extraHtml);
  }
View Full Code Here

  }
 
  @Test
  public void should_add_an_extraHtml_with_default_container() throws JspException, UnsupportedEncodingException {
   
    ExtraHtml extraHtml = new ExtraHtml();
    extraHtml.setContainer("div");
    extraHtml.setContent("<a href=\"http://myDomain.com\">Link</a><div>Content</div>");
    extraHtml.setUid("M");
    extraHtml.setCssClass("class1");
    extraHtml.setCssStyle("float:left");
   
    assertThat(table.getTableConfiguration().getExtraHtmlSnippets()).hasSize(1);
    assertThat(table.getTableConfiguration().getExtraHtmlSnippets()).contains(extraHtml);
  }
View Full Code Here

    String exportContainerStyle = TableConfig.EXPORT_CONTAINER_STYLE.valueFrom(table);
    String exportContainerClass = TableConfig.EXPORT_CONTAINER_CLASS.valueFrom(table);

    // In order to be easily positioned around the table, a DataTable
    // feature is created
    ExtraHtml extraHtml = new ExtraHtml();
    extraHtml.setUid("E");
    extraHtml.setContainer("div");
    extraHtml.setCssClass("dataTables_export "
        + (StringUtils.isNotBlank(exportContainerClass) ? exportContainerClass : ""));
    extraHtml.setCssStyle(StringUtils.isNotBlank(exportContainerStyle) ? exportContainerStyle : "float: right;");

    String dom = TableConfig.FEATURE_DOM.valueFrom(table);
    if (StringUtils.isBlank(dom)) {
      addParameter(DTConstants.DT_DOM, "lEfrtip", Mode.OVERRIDE);
    }

    StringBuilder content = new StringBuilder();
    HtmlHyperlink link = null;

    // A HTML link is generated for each ExportConf bean
    for (ExportConf conf : table.getTableConfiguration().getExportConfiguration().values()) {

      link = new HtmlHyperlink();

      if (conf.getCssClass() != null) {
        link.setCssClass(conf.getCssClass());
      }

      if (conf.getCssStyle() != null) {
        link.setCssStyle(conf.getCssStyle());
        link.addCssStyle(";margin-left:2px;");
      }
      else {
        link.addCssStyle("margin-left:2px;");
      }

      if (conf.hasCustomUrl()) {
        link.setOnclick(getOnclick(conf));
      }
      else {
        link.setHref(conf.getUrl());
      }
      link.addContent(conf.getLabel());
      content.append(link.toHtml());
    }
    extraHtml.setContent(content.toString());

    // Once created, the extraHtml is transformed into Javascript and
    // appended in the DataTables configuration
    appendToAfterStartDocumentReady(JavascriptGenerator.INDENTATION);
    appendToAfterStartDocumentReady(extraHtml.getJavascript().toString());
    appendToAfterStartDocumentReady(JavascriptGenerator.NEWLINE);
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  private void processExtraHtmlAttributes(Element element, Map<String, Map<ConfType, Object>> configs, String tableId) {
   
    if (hasAttribute(element, "uid")) {

      ExtraHtml extraHtml = new ExtraHtml();
      extraHtml.setUid(getStringValue(element, "uid"));

      if (hasAttribute(element, "container")) {
        extraHtml.setContainer(getStringValue(element, "container"));
      } else {
        extraHtml.setContainer("div");
      }

      if (hasAttribute(element, "cssStyle")) {
        extraHtml.setCssStyle(getStringValue(element, "cssStyle"));
      }
      if (hasAttribute(element, "cssClass")) {
        extraHtml.setCssClass(getStringValue(element, "cssClass"));
      }

      if (configs.get(tableId).containsKey(ConfType.EXTRAHTML)) {
        List<ExtraHtml> extraHtmls = (List<ExtraHtml>) configs.get(tableId).get(ConfType.EXTRAHTML);

        extraHtmls.add(extraHtml);
      }
      else {
        List<ExtraHtml> extraHtmls = new ArrayList<ExtraHtml>();
        extraHtmls.add(extraHtml);

        configs.get(tableId).put(ConfType.EXTRAHTML, extraHtmls);
      }

      // We add a fake div here, in order to be able to get the content
      // processed
      Element div = new Element("div");
      div.setAttribute(DataTablesDialect.DIALECT_PREFIX + ":tmp", "internalUseExtraHtml");
      div.setAttribute(DataTablesDialect.DIALECT_PREFIX + ":uid", extraHtml.getUid());
      element.getParent().addChild(div);
     
    }
    else {
      throw new ConfigurationProcessingException(
View Full Code Here

TOP

Related Classes of com.github.dandelion.datatables.core.html.ExtraHtml

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.