The class that administers the display data for the ListControl must only implement
the interface ListDataModel. It extends an existing class with methods for querying
the line objects within the list. The interface is thus kept simple.
import com.cc.framework.ui.model.ListDataModel;
/**
* Collection with UserDsp-Objects
*/
public class UserDisplayList implements ListDataModel {
private UserDsp[] data = new UserDsp[0];
public UserDisplayList(UserDsp[] elements) {
this.data = elements;
}
public Object getElementAt(int index) {
return data[index];
}
public int size() {
return data.length;
}
/**
* Unique Key for each Row (Object).
* In this Example our Key only contains the UserId.
*/
public String getUniqueKey(int index) {
return data[index].getUserId();
}
}
import com.cc.framework.common.DisplayObject;
import com.cc.sampleapp.common.UserRole;
/**
* User DisplayObject (ViewHelper)
*/
public class UserDsp implements DisplayObject {
private String userId = "";
private String firstName = "";
private String lastName = "";
private UserRole role = UserRole.NONE;
public UserDsp(String userId, String firstName,
String lastName, UserRole role) {
super();
this.userId = userId;
this.firstName = firstName;
this.lastName = lastName;
this.role = role;
}
public UserRole getRole() { return role; }
public String getUserId() { return userId; }
public String getLastName() { return lastName; }
public String getName() { return firstName + ", " + lastName; }
}
back |
continue to step 5
|