All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.bordertech.wcomponents.examples.table.SimpleTableExample Maven / Gradle / Ivy

There is a newer version: 1.5.36
Show newest version
package com.github.bordertech.wcomponents.examples.table;

import com.github.bordertech.wcomponents.Request;
import com.github.bordertech.wcomponents.SimpleBeanBoundTableModel;
import com.github.bordertech.wcomponents.WDateField;
import com.github.bordertech.wcomponents.WPanel;
import com.github.bordertech.wcomponents.WTable;
import com.github.bordertech.wcomponents.WTableColumn;
import com.github.bordertech.wcomponents.WText;

/**
 * This example demonstrates a simple {@link WTable} that is bean bound.
 * 

* Uses {@link SimpleBeanBoundTableModel} to handle the bean binding. *

* * @author Jonathan Austin * @since 1.0.0 */ public class SimpleTableExample extends WPanel { /** * The table used in the example. */ private final WTable table = new WTable(); /** * Create example. */ public SimpleTableExample() { add(table); // Columns table.addColumn(new WTableColumn("First name", new WText())); table.addColumn(new WTableColumn("Last name", new WText())); table.addColumn(new WTableColumn("DOB", new WDateField())); // Setup model SimpleBeanBoundTableModel model = new SimpleBeanBoundTableModel( new String[]{"firstName", "lastName", "dateOfBirth"}); table.setTableModel(model); } /** * Override preparePaintComponent in order to set up the example data the first time that the example is accessed by * each user. * * @param request the request being responded to. */ @Override protected void preparePaintComponent(final Request request) { super.preparePaintComponent(request); if (!isInitialised()) { // Set the data as the bean on the table table.setBean(ExampleDataUtil.createExampleData()); setInitialised(true); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy