Products
About Guided Tour Requirements
Resources
Documents Configuration examples TagLib Reference Useful Links
Customer Support
Updates Contact Services
Sales
Licensing Sales FAQ Buy Online
 
 
 
buy online   |   about us   |   german version  

» 3. Preparing the form data

For filling our form, we make use of a FormBean, the UserEditForm, which can be derived directly from org.apache.struts.action.ActionForm. The FormBean is, in our example, initialized in a simplified manner with our UserObject, which has previously loaded the data for the key transferred in the Request from a database.

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

import com.cc.framework.adapter.struts.ActionContext;
import com.cc.framework.adapter.struts.FWAction;

public class UserEditAction extends FWAction {

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

        String userId = ctx.request().getParameter("userid");

        try {
            // Load the User
            User user = new User(userId);
            user.load();

            // Initialise the Form with the User-Data
            UserEditForm form = (UserEditForm) ctx.form();
            form.setUser(user);

            // In our Example we store the UserObject
            // in our Session
            ctx.session().setAttribute("userobj", user);
        }
        catch (Throwable t) {
            ctx.addGlobalError("Error: ", t);
            ctx.forwardByName(Forwards.BACK);
        }

        // Call the JSP-Page with the Form
        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 Configuration