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 a Callback method:

For displaying the UserId the table uses a special column, a drilldown column. This triggers a hyperlink which, in our application, results in a branch to the detail view. The data should not be processed in this view. The Edit button is used for this.

To react suitably to this event, we include a corresponding Callback method in our UserBrowseAction. Since we do not wish to implement the business logic here, we forward the event to another action - UserDisplayAction. This can then load the detailed information and call the corresponding JSP page for display.

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.ControlActionContext;
import com.cc.framework.ui.control.SimpleListControl;

import com.cc.sampleapp.common.Forwards;
import com.cc.sampleapp.common.Messages;
import com.cc.sampleapp.dbaccess.DBUser;
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 {
            UserDisplayList dspData = DBUser.fetch();
            SimpleListControl userList = new SimpleListControl();
            userList.setDataModel(dspData);
            ctx.session().setAttribute("users", userList);
        }
        catch (Throwable t) {
            ctx.addGlobalError(Messages.ERROR, t);
        }

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

    /**
     * This Method is called when the Drilldown-Column is clicked
     * In our Example we switch to the DetailView, which shows
     * more Information about the User. It's a readonly View.
     * @param   ctx ControlActionContext
     * @param   key     UniqueKey, as it was defined in the UserDisplayList
     *          to identify the Row. In this Example the UserId.
     */
    public void users_onDrilldown(ControlActionContext ctx, String key) {
        ctx.forwardByName(Forwards.DRILLDOWN, key);
    }
}

The name of the CallBack is composed of the Property name of the TreeControl -the name of the Bean- and the event that has occurred. Since the ListControl was saved in the Session under the name "users" the name of the CallBack method is users_onDrilldown.

back   |   Layouts

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