It would help if you offer more examples or tutorials to your product. Your data layer has for example Property, Container and Item concepts and whole lot of different container implementations, how they are used in practise? And what is BeanItem class function under data.util package?
Testing version of 4.0.1 is accessible from
http://toolkit.itmill.com/testing , please have a look. It contains 14 new demos and source code for all the demos, including feature browser.
Could you provide an example of how to bind each item in a select to my own object?
If I select the item in a select, on the server side I’d like to get a reference to the same object that I have bound the item to. Events are not a problem.
Here is an example, replace it e.g. with com.itmill.toolkit.demo.SelectDemo:
package com.itmill.toolkit.demo;
import java.util.LinkedList;
import java.util.Random;
import com.itmill.toolkit.data.Property.ValueChangeEvent;
import com.itmill.toolkit.data.Property.ValueChangeListener;
import com.itmill.toolkit.ui.*;
public class SelectDemo extends com.itmill.toolkit.Application implements
ValueChangeListener {
private Select select = new Select();
private Label selectedTask = new Label("Selected task", Label.CONTENT_XHTML);
public LinkedList exampleTasks = new LinkedList();
public static Random random = new Random(1);
public void init() {
Window main = new Window("Select demo");
setMainWindow(main);
setTheme("corporate");
Panel panel = new Panel("Select demo");
panel.addComponent(select);
Panel panel2 = new Panel("Selection");
panel2.addComponent(selectedTask);
select.setCaption("Select component");
select.addListener((ValueChangeListener) this);
select.setImmediate(true);
main.addComponent(panel);
main.addComponent(panel2);
createExampleTasks();
}
public void createExampleTasks() {
String[] assignedTo = new String[]
{ "John", "Mary", "Joe", "Sarah",
"Jeff", "Jane", "Peter", "Marc", "Josie", "Linus" };
String[] type = new String[]
{ "Enhancement", "Bugfix", "Testing",
"Task" };
for (int j = 0; j < 100; j++) {
Task task = new Task(
type[(int) (random.nextDouble() * (type.length - 1))]
,
assignedTo[(int) (random.nextDouble() * (assignedTo.length - 1))]
,
random.nextInt(100));
select.addItem(task);
}
}
public void valueChange(ValueChangeEvent event) {
System.err.println("event=" + event);
Task task = (Task) select.getValue();
selectedTask.setValue("<b>Type:</b> " + task.getType()
+ "<br /><b>Assigned to:</b> " + task.getAssignedTo()
+ "<br /><b>Estimated hours: </b>" + task.getEstimatedHours());
}
public class Task {
private String type;
private String assignedTo;
private int estimatedHours;
public Task(String type, String assignedTo, int estimatedHours) {
this.type = type;
this.assignedTo = assignedTo;
this.estimatedHours = estimatedHours;
}
public String toString() {
return type + ", " + assignedTo;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getAssignedTo() {
return assignedTo;
}
public void setAssignedTo(String assignedTo) {
this.assignedTo = assignedTo;
}
public float getEstimatedHours() {
return estimatedHours;
}
public void setEstimatedHours(int estimatedHours) {
this.estimatedHours = estimatedHours;
}
}
}
Yes, I know our data model is a bit, let say too “academic” and hard grasp first. We have targeted task for Toolkit 5.0 release which makes most component’s data binding easier, most likely these changes are merged to Toolkit 4.0 too.