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  

» Exkurs: Implementation of Callback methods

The TreeListControl automatically generates an onDrilldown-Event on clicking on a label, to which the programmer can react within the action class.

To react to this event in our example, we include a corresponding Callback method in the RegionBrowseAction. Since we do not wish to implement the business logic here, we forward the event to another action - RegionDisplayAction.

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

public class RegionBrowseAction extends FWAction {

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

            try {
                RegionGroupDsp dspData = DBRegion.fetchDspOutline();

                TreelistControl regionList = new TreelistControl();
                regionList.setDataModel(dspData);

                ctx.session().setAttribute("regions", regionList);
            }

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

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

    // ------------------------------------------------
    //          TreeList-Control Event Handler
    // ------------------------------------------------


    /**
     * This Method is called when the TreeLabel is clicked
     * In our Example we switch to the DetailView, which shows
     * more Information about the node.
     * @param   ctx ControlActionContext
     * @param   key     UniqueKey, as created in the Datamodel
     */
    public void regions_onDrilldown(ControlActionContext ctx, String key) {
        ctx.forwardByName(Forwards.DRILLDOWN, key);
    }

}

The name of the CallBack method is composed of the property name of the TreeListControls - the name of the Bean - and the event that has occurred. Since the TreeListControl was stored under the name "region" in the session, the name of the CallBack-method is regions_onDrilldown.

back

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