Products
About Guided Tour Online Demo Trial Version Requirements
Resources
Documents Configuration examples TagLib Reference Useful Links
Customer Support
Updates Forums Contact Services
Sales
Licensing Sales FAQ Buy Online
 
 
 
buy online   |   about us   |   german version  

» 4. Provision of the display data

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

Impressum | This product includes software developed by the Java Apache Project
Tours
ListControl TreeControl TreeListControl TabSetControl Form Tags MenuControl Print version Live Demo Configuration