membersound
membersound

Reputation: 86657

Fill a tree component in GWT from view side on

I'm creating a GWT Tree Component like this in code:

// Create a tree with a few items in it.
    TreeItem root = new TreeItem();
    root.setText("root");
    root.addTextItem("item0");
    root.addTextItem("item1");
    root.addTextItem("item2");

    // Add a CheckBox to the tree
    TreeItem item = new TreeItem(new CheckBox("item3"));
    root.addItem(item);

    Tree t = new Tree();
    t.addItem(root);

    // Add it to the root panel.
    RootPanel.get().add(t);

But I don't like the mix of gui and value-code here. Coming from JSF I'm used to having a xhtml file which defines the tree, and a backing class that provides the values for the tree.

How can I achieve the same separation in GWT?

Upvotes: 0

Views: 128

Answers (1)

appbootup
appbootup

Reputation: 9537

You should be using CellTree api instead. Reference example - http://gwt.googleusercontent.com/samples/Showcase/Showcase.html#!CwCellTree

I could not figure out your GWT version. CellTree is available since GWT 2.1 as part of Cell Widgets hierarchy.

Note - You probably will like to use it with Data Provider concepts in GWT for better GUI/Data segretation.

Upvotes: 1

Related Questions