question about table

I created a simple UI, which has a table. It supposed to work like this: click one row in the table, then customlayout remove all components and add new components.

But now I have to refresh the page to see thoes new components after I click the table row. I think I already set table properties as following:


Can you explain this in more detail? What is the role of the CustomLayout?

This should be otherwise ok, but the way you try to use the paging table is obsolete. In Toolkit Release 5, there is no more setStyle() and setStyleName() sets only CSS style name and does not control a variation of a component as setStyle() did in Release 4. Release 5 provides new server-side components for the classes. For the paging table, in the client-side there actually already is ITablePaging, but it has not yet a server-side counterpart. So, I recommend using just the scrollable Table for the moment.

I’ll look if there’s some problem with selecting items from tables.

At least the following code for handling ValueChange events seems to work ok.


public class TableExample extends CustomComponent {
    /* Create the table with a caption. */
    Table table = new Table("This is my Table");

    /* A layout needed for the example. */
    OrderedLayout layout = new OrderedLayout(OrderedLayout.ORIENTATION_VERTICAL);

    /* Feedback for selecting items from the table. */
    Label current = new Label("Selected: -");

    TableExample() {

        /* Define the names, data types, and default values of columns. */
        table.addContainerProperty("First Name", String.class,
                "(no first name)");
        table.addContainerProperty("Last Name", String.class, "(no last name)");
        table.addContainerProperty("Year", Integer.class, null);

        /* We use these entries to generate random items in a table. */
        final String[] firstnames = new String[]
 { "Donald", "Patty", "Sally",
                "Douglas" };
        final String[] lastnames = new String[]
 { "Smith", "Jones", "Adams",
                "Knuth" };

        /* Add some items in the table and assign them an Item ID (IID). */
        for (int i = 0; i < 500; i++) {
            /* Add a randomly generated item in the Table. */
            table.addItem(new Object[] {
                        firstnames[(int) (Math.random() * (firstnames.length - 0.01))]
                        lastnames[(int) (Math.random() * (lastnames.length - 0.01))]
                        new Integer((int) (1900 + Math.random() * 100)) },
                    new Integer(i));

        /* Set the number of items visible in the table. */

        /* Enable some UI features for the table. */

        /* Allow selecting items from the table. */
        /* When an item is selected, the selection is sent immediately to server. */
        /* Handle selection change. */
        table.addListener(new Property.ValueChangeListener() {
            public void valueChange(ValueChangeEvent event) {
                current.setValue("Selected: " + table.getValue().toString());

It’s hard to say what your problem could be. If you have installed a new nightly build, for example, and have some trouble, always refresh the project (F5), restart the server, and possibly also the browser.