Package org.apache.click.control

Examples of org.apache.click.control.Table


                    processControl(childControl);
                }
            }

        } else if (control instanceof Table) {
            Table table = (Table) control;
            if (table.hasControls()) {
                for (Control childControl : table.getControls()) {
                    processControl(childControl);
                }
            }
        }
    }
View Full Code Here


    private CustomerService customerService;

    // Constructor ------------------------------------------------------------

    public TableFooter() {
        table = new Table() {
            private static final long serialVersionUID = 1L;

            @Override
            public void renderFooterRow(HtmlStringBuffer buffer) {
                renderTotalHoldingsFooter(buffer);
View Full Code Here

    private Table table;

    // Constructor ------------------------------------------------------------

    public SimpleTablePage() {
        table = new Table("table");

        table.setClass(Table.CLASS_ITS);

        table.addColumn(new Column("id"));
        table.addColumn(new Column("name"));
View Full Code Here

    @Resource(name="customerService")
    private CustomerService customerService;

    public TableSorting() {
        final Table table = new Table("table");

        // Setup customers table
        table.setClass(Table.CLASS_SIMPLE);
        table.setHoverRows(true);
        table.setSortable(true);

        Column column = new Column("id");
        column.setSortable(false);
        table.addColumn(column);

        table.addColumn(new Column("name"));

        column = new Column("email");
        column.setAutolink(true);
        table.addColumn(column);

        column = new Column("age");
        column.setTextAlign("center");
        table.addColumn(column);

        column = new Column("holdings");
        column.setFormat("${0,number,#,##0.00}");
        column.setTextAlign("right");
        table.addColumn(column);

        column = new Column("active");
        column.setTextAlign("center");
        table.addColumn(column);

        // Return sorted data to the table.
        table.setDataProvider(new DataProvider<Customer>() {
            public List<Customer> getData() {
                boolean useSharedCache = true;
                return customerService.getCustomersSortedBy(table.getSortedColumn(),
                                                            table.isSortedAscending(),
                                                            useSharedCache);
            }
        });

        table.setSorted(true);

        addControl(table);
    }
View Full Code Here

    private CustomerService customerService;

    // Constructor ------------------------------------------------------------

    public LargeDatasetDemo() {
        table = new Table();

        // Setup customers table
        table.setClass(Table.CLASS_ITS);
        table.setSortable(true);
View Full Code Here

     *
     * @param buffer the string buffer to render the paginator to
     */
    @Override
    public void render(HtmlStringBuffer buffer) {
        final Table table = getTable();

        if (table == null) {
            throw new IllegalStateException("No parent table defined."
                + " Ensure a parent Table is set using #setTable(Table).");
        }

        final ActionLink controlLink = table.getControlLink();

        if (table.getSortedColumn() != null) {
            controlLink.setParameter(Table.SORT, null);
            controlLink.setParameter(Table.COLUMN, table.getSortedColumn());
            controlLink.setParameter(Table.ASCENDING, String.valueOf(table.isSortedAscending()));
        } else {
            controlLink.setParameter(Table.SORT, null);
            controlLink.setParameter(Table.COLUMN, null);
            controlLink.setParameter(Table.ASCENDING, null);
        }

        String firstLabel = "";
        String previousLabel = "";

        if (table.getPageNumber() > 0) {
            controlLink.setDisabled(false);
            controlLink.setImageSrc(paginatorMessages.getMessage("table-inline-first-image"));
            controlLink.setParameter(Table.PAGE, String.valueOf(0));
            controlLink.setTitle(table.getMessage("table-first-title"));
            firstLabel = controlLink.toString();

            controlLink.setImageSrc(paginatorMessages.getMessage("table-inline-previous-image"));
            controlLink.setParameter(Table.PAGE, String.valueOf(table.getPageNumber() - 1));
            controlLink.setTitle(table.getMessage("table-previous-title"));
            previousLabel = controlLink.toString();

        } else {
            controlLink.setDisabled(true);

            controlLink.setImageSrc(paginatorMessages.getMessage("table-inline-first-disabled-image"));
            controlLink.setParameter(Table.PAGE, null);
            controlLink.setTitle(null);
            firstLabel = controlLink.toString();

            controlLink.setImageSrc(paginatorMessages.getMessage("table-inline-previous-disabled-image"));
            controlLink.setParameter(Table.PAGE, null);
            controlLink.setTitle(null);
            previousLabel = controlLink.toString();
        }

        HtmlStringBuffer pagesBuffer =
            new HtmlStringBuffer(table.getNumberPages() * 70);

        // Create sliding window of paging links
        int lowerBound = Math.max(0, table.getPageNumber() - 5);
        int upperBound = Math.min(lowerBound + 10, table.getNumberPages());
        if (upperBound - lowerBound < 10) {
            lowerBound = Math.max(upperBound - 10, 0);
        }

        controlLink.setImageSrc(null);
        controlLink.setDisabled(false);
        String gotoTitle = table.getMessage("table-goto-title");

        for (int i = lowerBound; i < upperBound; i++) {
            String pageNumber = String.valueOf(i + 1);
            if (i == table.getPageNumber()) {
                pagesBuffer.append("<strong>" + pageNumber + "</strong>");

            } else {
                controlLink.setLabel(pageNumber);
                controlLink.setParameter(Table.PAGE, String.valueOf(i));
                controlLink.setTitle(gotoTitle + " " + pageNumber);
                pagesBuffer.append(controlLink.toString());
            }

            if (i < upperBound - 1) {
                pagesBuffer.append("&#160; ");
            }
        }

        String nextLabel = "";
        String lastLabel = "";

        if (table.getPageNumber() < table.getNumberPages() - 1) {
            controlLink.setDisabled(false);
            controlLink.setImageSrc(paginatorMessages.getMessage("table-inline-next-image"));
            controlLink.setParameter(Table.PAGE, String.valueOf(table.getPageNumber() + 1));
            controlLink.setTitle(table.getMessage("table-next-title"));
            nextLabel = controlLink.toString();

            controlLink.setImageSrc(paginatorMessages.getMessage("table-inline-last-image"));
            controlLink.setParameter(Table.PAGE, String.valueOf(table.getNumberPages() - 1));
            controlLink.setTitle(table.getMessage("table-last-title"));
            lastLabel = controlLink.toString();

        } else {
            controlLink.setDisabled(true);

View Full Code Here

                    processControl((Control) controls.get(i));
                }
            }

        } else if (control instanceof Table) {
            Table table = (Table) control;
            if (table.hasControls()) {
                List controls = table.getControls();
                for (int i = 0, size = controls.size(); i < size; i++) {
                    processControl((Control) controls.get(i));
                }
            }
        }
View Full Code Here

    @Resource(name="customerService")
    private CustomerService customerService;

    public LargeDatasetDemo() {
        table = new Table();

        // Setup customers table
        table.setClass(Table.CLASS_ITS);

        Column column = new Column("name");
View Full Code Here

     * @see org.apache.click.control.Renderable#render(HtmlStringBuffer)
     *
     * @param buffer the string buffer to render the paginator to
     */
    public void render(HtmlStringBuffer buffer) {
        final Table table = getTable();

        if (table == null) {
            throw new IllegalStateException("No parent table defined."
                + " Ensure a parent Table is set using #setTable(Table).");
        }

        final ActionLink controlLink = table.getControlLink();

        if (table.getSortedColumn() != null) {
            controlLink.setParameter(Table.SORT, null);
            controlLink.setParameter(Table.COLUMN, table.getSortedColumn());
            controlLink.setParameter(Table.ASCENDING, String.valueOf(table.isSortedAscending()));
        } else {
            controlLink.setParameter(Table.SORT, null);
            controlLink.setParameter(Table.COLUMN, null);
            controlLink.setParameter(Table.ASCENDING, null);
        }

        String firstLabel = "";
        String previousLabel = "";

        if (table.getPageNumber() > 0) {
            controlLink.setDisabled(false);
            controlLink.setImageSrc(paginatorMessages.getMessage("table-inline-first-image"));
            controlLink.setParameter(Table.PAGE, String.valueOf(0));
            controlLink.setTitle(table.getMessage("table-first-title"));
            firstLabel = controlLink.toString();

            controlLink.setImageSrc(paginatorMessages.getMessage("table-inline-previous-image"));
            controlLink.setParameter(Table.PAGE, String.valueOf(table.getPageNumber() - 1));
            controlLink.setTitle(table.getMessage("table-previous-title"));
            previousLabel = controlLink.toString();

        } else {
            controlLink.setDisabled(true);

            controlLink.setImageSrc(paginatorMessages.getMessage("table-inline-first-disabled-image"));
            controlLink.setParameter(Table.PAGE, null);
            controlLink.setTitle(null);
            firstLabel = controlLink.toString();

            controlLink.setImageSrc(paginatorMessages.getMessage("table-inline-previous-disabled-image"));
            controlLink.setParameter(Table.PAGE, null);
            controlLink.setTitle(null);
            previousLabel = controlLink.toString();
        }

        HtmlStringBuffer pagesBuffer =
            new HtmlStringBuffer(table.getNumberPages() * 70);

        // Create sliding window of paging links
        int lowerBound = Math.max(0, table.getPageNumber() - 5);
        int upperBound = Math.min(lowerBound + 10, table.getNumberPages());
        if (upperBound - lowerBound < 10) {
            lowerBound = Math.max(upperBound - 10, 0);
        }

        controlLink.setImageSrc(null);
        controlLink.setDisabled(false);
        String gotoTitle = table.getMessage("table-goto-title");

        for (int i = lowerBound; i < upperBound; i++) {
            String pageNumber = String.valueOf(i + 1);
            if (i == table.getPageNumber()) {
                pagesBuffer.append("<strong>" + pageNumber + "</strong>");

            } else {
                controlLink.setLabel(pageNumber);
                controlLink.setParameter(Table.PAGE, String.valueOf(i));
                controlLink.setTitle(gotoTitle + " " + pageNumber);
                pagesBuffer.append(controlLink.toString());
            }

            if (i < upperBound - 1) {
                pagesBuffer.append("&#160; ");
            }
        }

        String nextLabel = "";
        String lastLabel = "";

        if (table.getPageNumber() < table.getNumberPages() - 1) {
            controlLink.setDisabled(false);
            controlLink.setImageSrc(paginatorMessages.getMessage("table-inline-next-image"));
            controlLink.setParameter(Table.PAGE, String.valueOf(table.getPageNumber() + 1));
            controlLink.setTitle(table.getMessage("table-next-title"));
            nextLabel = controlLink.toString();

            controlLink.setImageSrc(paginatorMessages.getMessage("table-inline-last-image"));
            controlLink.setParameter(Table.PAGE, String.valueOf(table.getNumberPages() - 1));
            controlLink.setTitle(table.getMessage("table-last-title"));
            lastLabel = controlLink.toString();

        } else {
            controlLink.setDisabled(true);

View Full Code Here

    @Resource(name="customerService")
    private CustomerService customerService;

    public TableFooter() {
        table = new Table() {
            public void renderFooterRow(HtmlStringBuffer buffer) {
                renderTotalHoldingsFooter(buffer);
            }
        };
View Full Code Here

TOP

Related Classes of org.apache.click.control.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.