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 of the TreeControl

Now, the TreeControl is instanced within our action and filled with the display data. The data model is assigned to the control element through the setDataModel()-method. The method takes, as the argument, an object of type TreeGroupDataModel. What this involves is an interface which provides access to the display data of the tree. It is the job of the application developer to provide a corresponding implementation.

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.TreeControl;

public class ProductTreeBrowseAction extends FWAction {

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

        try {
            // first we get the Data for our Tree
            ProductGroupDsp data = DBProduct.fetch();

            // secondly create the TreeControl and populate it
        // with the Data to display
            TreeControl products = new TreeControl();
            products.setDataModel(data);

        // third put the TreeControl into the Session-Object.
            // Our Control is a statefull Object.
            ctx.session().setAttribute("products", products);
        }

        catch (Throwable t) {
            ctx.addGlobalError("Error: ", t);
        }

        // Display the Page with the Tree
        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