Package org.apache.ecs.xhtml

Examples of org.apache.ecs.xhtml.table


    }
   
    private String renderResults( Collection results, WikiContext context, int maxItems )
    {
        WikiEngine engine = context.getEngine();
        table t = new table();
        t.setBorder(0);
        t.setCellPadding(4);

        tr row = new tr();
        t.addElement( row );
       
        row.addElement( new th().setWidth("30%").setAlign("left").addElement("Page") );
        row.addElement( new th().setAlign("left").addElement("Score"));

        int idx = 0;
        for( Iterator i = results.iterator(); i.hasNext() && idx++ <= maxItems; )
        {
            SearchResult sr = (SearchResult) i.next();
            row = new tr();
           
            td name = new td().setWidth("30%");
            name.addElement( "<a href=\""+
                             context.getURL( WikiContext.VIEW, sr.getPage().getName() )+
                             "\">"+engine.beautifyTitle(sr.getPage().getName())+"</a>");
            row.addElement( name );
           
            row.addElement( new td().addElement(""+sr.getScore()));
           
            t.addElement( row );
        }
       
        if( results.isEmpty() )
        {
            row = new tr();
           
            row.addElement( new td().setColSpan(2).addElement( new b().addElement("No results")));

            t.addElement(row);
        }
       
        return t.toString();
    }
View Full Code Here


    {
      String cssPrefix = extension != null ? extension.getClassPrefix() : null;
      if (cssPrefix != null && cssPrefix.trim().length() == 0)
        cssPrefix = null;
     
      table table = new table();
      if (cssPrefix != null)
        table.setClass(cssPrefix + "-table");
      //
      //  for all rows (-1 = header row)
      for (int row = -1; row < m_printData.getRowCount(); row++)
      {
        tr tr = new tr();
        table.addElement(tr);
        if (row != -1)
        {
          m_printData.setRowIndex(row);         
          if (extension != null)
          {
            extension.extendRowElement(tr, m_printData);
          }
        }
        //  for all columns
        for (int col = 0; col < m_printFormat.getItemCount(); col++)
        {
          MPrintFormatItem item = m_printFormat.getItem(col);
          if (item.isPrinted())
          {
            //  header row
            if (row == -1)
            {
              th th = new th();
              tr.addElement(th);
              th.addElement(Util.maskHTML(item.getPrintName(language)));
            }
            else
            {
              td td = new td();
              tr.addElement(td);
              Object obj = m_printData.getNode(new Integer(item.getAD_Column_ID()));
              if (obj == null)
                td.addElement("&nbsp;");
              else if (obj instanceof PrintDataElement)
              {
                PrintDataElement pde = (PrintDataElement) obj;
                String value = pde.getValueDisplay(language)//  formatted
                if (pde.getColumnName().endsWith("_ID") && extension != null)
                {
                  //link for column
                  a href = new a("javascript:void(0)");                 
                  href.setID(pde.getColumnName() + "_" + row + "_a");                 
                  td.addElement(href);
                  href.addElement(Util.maskHTML(value));
                  if (cssPrefix != null)
                    href.setClass(cssPrefix + "-href");
                 
                  extension.extendIDColumn(row, td, href, pde);
                                                     
                }
                else
                {
                  td.addElement(Util.maskHTML(value));
                }
                if (cssPrefix != null)
                {
                  if (DisplayType.isNumeric(pde.getDisplayType()))
                    td.setClass(cssPrefix + "-number");
                  else if (DisplayType.isDate(pde.getDisplayType()))
                    td.setClass(cssPrefix + "-date");
                  else
                    td.setClass(cssPrefix + "-text");
                }               
              }
              else if (obj instanceof PrintData)
              {
                //  ignore contained Data
              }
              else
                log.log(Level.SEVERE, "Element not PrintData(Element) " + obj.getClass());
            }
          }  //  printed
        //  for all columns
      //  for all rows

      //
      PrintWriter w = new PrintWriter(writer);
      if (onlyTable)
        table.output(w);
      else
      {
        XhtmlDocument doc = new XhtmlDocument();
        doc.appendBody(table);
        if (extension.getStyleURL() != null)
View Full Code Here

TOP

Related Classes of org.apache.ecs.xhtml.table

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.