Package org.displaytag.model

Examples of org.displaytag.model.TableModel


     * ToString() test.
     */
    @Test
    public void testTableModel()
    {
        checkToString(new TableModel(null, null, null));
    }
View Full Code Here


{

    TableModel getModel()
    {
        TableProperties props = TableProperties.getInstance(null);
        TableModel model = new TableModel(props, "", null);
        model.setRowListPage(model.getRowListFull());
        {
            HeaderCell ha = new HeaderCell();
            ha.setTitle("ColumnAnt");
            ha.setBeanPropertyName("ant");
            ha.setHtmlAttributes(new HtmlAttributeMap());
            ha.setGroup(1);
            model.addColumnHeader(ha);
        }
        {
            HeaderCell hb = new HeaderCell();
            hb.setTitle("Column2");
            hb.setHtmlAttributes(new HtmlAttributeMap());
            hb.setBeanPropertyName("bee");
            hb.setGroup(2);
            model.addColumnHeader(hb);
        }
        {
            HeaderCell hb = new HeaderCell();
            hb.setTitle("long");
            hb.setBeanPropertyName("camel");
            hb.setTotaled(false);
            HtmlAttributeMap mm = new HtmlAttributeMap();
            mm.put(TagConstants.ATTRIBUTE_STYLE, "font-weight: bold; text-align: right");
            mm.put(TagConstants.ATTRIBUTE_CLASS, new MultipleHtmlAttribute("right rowish"));
            hb.setHtmlAttributes(mm);
            model.addColumnHeader(hb);
        }
        {
            HeaderCell hb = new HeaderCell();
            hb.setTitle("Column3");
            hb.setHtmlAttributes(new HtmlAttributeMap());
            hb.setBeanPropertyName("two");
            hb.setTotaled(true);
            model.addColumnHeader(hb);
        }
        model.addRow(new Row(new KnownValue(), 0));
        model.addRow(new Row(new KnownValue(), 1));
        KnownValue third = new KnownValue();
        third.beeValue = "BeeAnt";
        third.twoValue = 3;
        third.camelValue = "arealllylongtextstringthatshouldforceafailuretowrapontheoutputline";
        // third.camelValue = "a reallly long text string that should force a failure to wrap on the output line";
        model.addRow(new Row(third, 2));
        KnownValue antv = new KnownValue();
        antv.antValue = "bee";
        antv.twoValue = 4;
        model.addRow(new Row(antv, 3));
        return model;
    }
View Full Code Here

    }

    @Test
    public void testSimpleTotalsCorrect() throws Exception
    {
        TableModel m = getModel();
        TableTotaler tt = new TableTotaler();
        m.setTotaler(tt);
        tt.init(m);
        XmlTotalsWriter tw = new XmlTotalsWriter(m);
        tw.writeTable(m, "safd");
        String xml = tw.getXml();
        assertXpathEvaluatesTo("11.0", "//subgroup[@grouped-by=0]/subtotal/subtotal-cell[4]", xml);
View Full Code Here

{

    TableModel getModel()
    {
        TableProperties props = TableProperties.getInstance(null);
        TableModel model = new TableModel(props, "", null);
        model.setRowListPage(model.getRowListFull());
        {
            HeaderCell ha = new HeaderCell();
            ha.setTitle("ColumnAnt");
            ha.setBeanPropertyName("ant");
            ha.setHtmlAttributes(new HtmlAttributeMap());
            ha.setGroup(1);
            model.addColumnHeader(ha);
        }
        {
            HeaderCell hb = new HeaderCell();
            hb.setTitle("Column2");
            hb.setHtmlAttributes(new HtmlAttributeMap());
            hb.setBeanPropertyName("bee");
            hb.setGroup(2);
            model.addColumnHeader(hb);
        }
        {
            HeaderCell hb = new HeaderCell();
            hb.setTitle("long");
            hb.setBeanPropertyName("camel");
            hb.setTotaled(false);
            HtmlAttributeMap mm = new HtmlAttributeMap();
            mm.put(TagConstants.ATTRIBUTE_STYLE, "font-weight: bold; text-align: right");
            mm.put(TagConstants.ATTRIBUTE_CLASS, new MultipleHtmlAttribute("right rowish"));
            hb.setHtmlAttributes(mm);
            model.addColumnHeader(hb);
        }
        {
            HeaderCell hb = new HeaderCell();
            hb.setTitle("Column3");
            hb.setHtmlAttributes(new HtmlAttributeMap());
            hb.setBeanPropertyName("two");
            hb.setTotaled(true);
            model.addColumnHeader(hb);
        }
        {
            HeaderCell hb = new HeaderCell();
            hb.setTitle("DateColumn");
            hb.setHtmlAttributes(new HtmlAttributeMap());
            hb.setBeanPropertyName("date");
            model.addColumnHeader(hb);
        }
        model.addRow(new Row(new KnownValue(), 0));
        model.addRow(new Row(new KnownValue(), 0));
        model.addRow(new Row(new KnownValue(), 1));
        KnownValue third = new KnownValue();
        third.beeValue = "BeeAnt";
        third.twoValue = 3;
        third.camelValue = "arealllylongtextstringthatshouldforceafailuretowrapontheoutputlasdfasdfddine";
        // third.camelValue = "a reallly long text string that should force a failure to wrap on the output line";
        model.addRow(new Row(third, 2));
        KnownValue antv = new KnownValue();
        antv.antValue = "anteater";
        antv.twoValue = 4;
        model.addRow(new Row(antv, 3));
        return model;
    }
View Full Code Here

    }

    @Test
    public void testNoGroups() throws Exception
    {
        TableModel m = getModel();
        for (HeaderCell cell : m.getHeaderCellList())
        {
            cell.setGroup(0);
        }
        TableTotaler tt = new TableTotaler();
        m.setTotaler(tt);
        HssfDoubleExportView view = new HssfDoubleExportView();
        tt.init(m);
        view.setParameters(m, true, true, true);

        File f = File.createTempFile("nogroups", null);
View Full Code Here

    }

    @Test
    public void testSimpleTotalsCorrect() throws Exception
    {
        TableModel m = getModel();
        TableTotaler tt = new TableTotaler();
        m.setTotaler(tt);
        HssfDoubleExportView view = new HssfDoubleExportView();
        tt.init(m);
        view.setParameters(m, true, true, true);

        File f = File.createTempFile("displaytag", null);
View Full Code Here

        {
            log.debug("[" + getUid() + "] doStartTag called");
        }

        this.properties = TableProperties.getInstance(pageContext);
        this.tableModel = new TableModel(this.properties, pageContext.getResponse().getCharacterEncoding(), pageContext);

        // copying id to the table model for logging
        this.tableModel.setId(getUid());
        this.tableModel.setForm(this.form);
View Full Code Here

        TableProperties props = TableProperties.getInstance(null);
        SmartListHelper helper = new SmartListHelper(data, data.size(), 10, props, false);
        helper.setCurrentPage(1);
        List fullList = helper.getListForCurrentPage();

        TableModel model = new TableModel(props, "", null);
        model.setRowListPage(fullList);
        model.setPageOffset(helper.getFirstIndexForCurrentPage());

        MultilevelTotalTableDecorator decorator = new MultilevelTotalTableDecorator();
        decorator.init(null, rawData, model);
        model.setTableDecorator(decorator);

        RowIterator iterator = model.getRowIterator(false);
        while (iterator.hasNext())
        {
            iterator.next();
        }
View Full Code Here

        TableProperties props = TableProperties.getInstance(null);
        SmartListHelper helper = new SmartListHelper(data, data.size(), 5, props, false);
        helper.setCurrentPage(1);
        List fullList = helper.getListForCurrentPage();

        TableModel model = new TableModel(props, "", null);
        model.setRowListPage(fullList);
        model.setPageOffset(helper.getFirstIndexForCurrentPage());

        MultilevelTotalTableDecorator decorator = new MultilevelTotalTableDecorator();
        decorator.init(null, rawData, model);
        model.setTableDecorator(decorator);

        RowIterator iterator = model.getRowIterator(false);
        while (iterator.hasNext())
        {
            iterator.next();
        }
View Full Code Here

        TableProperties props = TableProperties.getInstance(null);
        SmartListHelper helper = new SmartListHelper(data, data.size(), 5, props, false);
        helper.setCurrentPage(2);
        List fullList = helper.getListForCurrentPage();

        TableModel model = new TableModel(props, "", null);
        model.setRowListPage(fullList);
        model.setPageOffset(helper.getFirstIndexForCurrentPage());

        MultilevelTotalTableDecorator decorator = new MultilevelTotalTableDecorator();
        decorator.init(null, rawData, model);
        model.setTableDecorator(decorator);

        RowIterator iterator = model.getRowIterator(false);
        while (iterator.hasNext())
        {
            iterator.next();
        }
View Full Code Here

TOP

Related Classes of org.displaytag.model.TableModel

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.