FileDocCategorySizeDatePackage
Ch10_04.javaAPI DocExample1396Mon Dec 01 15:08:26 GMT 2003org.eclipsebook.ch10

Ch10_04.java

package org.eclipsebook.ch10;

import org.eclipsebook.ch10.Ch10_06;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.*;

public class Ch10_04 extends Action 
{
    public ActionForward execute(ActionMapping mapping,
				 ActionForm form,
				 HttpServletRequest request,
				 HttpServletResponse response)
	throws Exception {

        ActionErrors actionerrors = new ActionErrors();
                
        Ch10_06 orderForm = (Ch10_06)form;
        
        String email = orderForm.getEmail();        
        if(email.trim().equals("")) {
            actionerrors.add(ActionErrors.GLOBAL_ERROR, new ActionError("error.noemail"));
        }
        
        String type = orderForm.getType();        
        if(type.trim().equals("")) {
            actionerrors.add("ActionErrors.GLOBAL_ERROR", new ActionError("error.notype"));
        }
        
        String[] items = orderForm.getItems();        
        if(items == null) {
            actionerrors.add("ActionErrors.GLOBAL_ERROR", new ActionError("error.noitems"));
        }
            
        if(actionerrors.size() != 0) {            
            saveErrors(request, actionerrors);
            return new ActionForward(mapping.getInput());            
        }

        return mapping.findForward("OK");
    }
}