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  

» 5. Implementation of the Callback methods

The Back- and Save buttons in our form each generate a click event, to which we can react within our action by incorporating two Callback methods. The name of the method is composed of the name of the button and the suffix onClick. Form buttons must then be named with the prefix "btn". Otherwise, no Callback method is invoked. The button btnBack thus results in a call to the method back_onClick. The method is then passed on to the FormActionContext, which capsulates the access to the Request-, Session Object and the FormBean.

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.adapter.struts.FormActionContext;

public class UserEditAction extends FWAction {

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

    // ------------------------------------------------
    //               Event Handler
    // ------------------------------------------------

    /**
     * This Method is called when the Back-Button is pressed.
     * @param   ctx FormActionContext
     */
    public void back_onClick(FormActionContext ctx) {
        ctx.forwardByName(Forwards.BACK);
    }

    /**
     * This Method is called when the Save-Button is pressed.
     * @param   ctx FormActionContext
     */
    public void save_onClick(FormActionContext ctx) {
        // See next Chapter
    }

}


back   |   continue to step 6

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