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  

» 3. Instancing the ListControl

Now, the ListControl is instanced within the UserBrowseAction and filled with the data to be displayed. To do so, using the setDataModel() method, its data model is assigned to the control element. The method setDataModel() takes up, as an argument, a ListDataModel. What is involved here is a simple interface, which is implemented by the class UserDisplayList, which provides the display data.

import java.io.IOException;
import javax.servlet.ServletException;

import com.cc.framework.adapter.struts.ActionContext;
import com.cc.framework.adapter.struts.FWAction;
import com.cc.framework.ui.control.SimpleListControl;

import com.cc.sampleapp.common.Messages;
import com.cc.sampleapp.presentation.dsp.UserDisplayList;

public class UserBrowseAction extends FWAction {

    /**
     * @see com.cc.framework.adapter.struts.FWAction#doExecute(ActionContext)
     */
    public void doExecute(ActionContext ctx)
        throws IOException, ServletException {

        try {
            // Get the Displaydata for our List
            UserDisplayList dspData = DBUser.fetch();

            // Create the ListControl and populate it.
            // with the Data to be displayed
            SimpleListControl userList = new SimpleListControl();
            userList.setDataModel(dspData);

            // Put the ListControl into the Session-Object.
            // Our ListControl is a statefull Object.
            ctx.session().setAttribute("users", userList);
        }
        catch (Throwable t) {
            ctx. AddGlobalError(Messages.ERROR, t);
        }

        // Display the Page with the UserList
        ctx.forwardToInput();
    }
}

back   |   continue to step 4

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