Table

Documentation

Table component that uses TableModel and RowSorter to render, like JTable on swing framework. It is a good component to present data that don't need complex layout presentation, has an dynamic number of columns, or the cell may to be editable or not depending on a not obvious condition.

Example:

You can create your table model and pass it to Table constructor. Settings as column names, editable cells, values and operations will to be managed by Table.

TableModel tableModel = new DefaultTableModel(values.length, values[0].length)
{
	@Override
	public boolean isCellEditable(int row, int column)
	{
		return column == 2;
	}

	@Override
	public Object getValueAt(int row, int column)
	{
		return values[row][column];
	}

	@Override
	public void setValueAt(Object aValue, int row, int column)
	{
		values[row][column] = aValue;
		editionLabel.setDefaultModelObject("value changed to " + aValue);
		AjaxRequestTarget.get().addComponent(editionLabel);
	}
};
table = new Table("table", tableModel)
{
	@Override
	protected void onSelection(AjaxRequestTarget target)
	{
		target.addComponent(viewSelection);
		target.addComponent(modelSelection);
	}
};

It is possible to specify that the table will use an RowSorter (from swing api) to access the TableModel values at an specific order. If so, the component will start to handle column headers events to update ordering rules.

table.setRowSorter(sorter);

It is important to note that the sorter object maintain his state during the session and need to be serializable. This project has an SerializableTableRowSorter that can to be used.
The simplest way to get you table sorted is simple call setAutoCreateRowSorter method from the Table class!

table.setAutoCreateRowSorter(true);

The component can have navigator for his rows and columns. Factory methods are avaliable for this:

table.setRowsPerPage(4);
add(table.getRowsAjaxPagingNavigator("rowsPaging"));
table.setColumnsPerPage(4);
add(table.getColumnsAjaxPagingNavigator("columnsPaging"));

It is possible to specify the table selection mode available at ListSelectionMode. Once SINGLE_INTERVAL_SELECTION or MULTIPLE_INTERVAL_SELECTION are specified, the selection handler will test shiftKey and the ctrlKey pressed with the mouse, allowing the user interation looks like the one with desktop tables.

table.setSelectionMode(ListSelectionMode.SINGLE_INTERVAL_SELECTION);

 To customize the way that table display the cells values:

Renders and editors to table 

Preview

 

Project maintainers

Pedro Santos
pedrosans@gmai.com

SVN Repository

https://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/table-parent/table

Example

The example project are available at:
https://wicket-stuff.svn.sourceforge.net/svnroot/wicket-stuff/trunk/table-parent/table-examples/

Make sure you have installed the table project on your local maven repository and you can start the example with:

mvn jetty:run

and access the example page at:

http://localhost:8080/table-examples/


Browse Space

- Pages
- News
- Labels
- Attachments
- Bookmarks
- Mail
- Advanced
- Activity

Explore Confluence

- Popular Labels
- Notation Guide

Your Account

Log In

or Sign Up  

Other Features

Add Content