1 package action; 2 3 import javax.servlet.http.HttpServletRequest ; 4 import javax.servlet.http.HttpServletResponse ; 5 6 import org.apache.struts.action.Action; 7 import org.apache.struts.action.ActionForm; 8 import org.apache.struts.action.ActionForward; 9 import org.apache.struts.action.ActionMapping; 10 import org.objectstyle.cayenne.access.DataContext; 11 import org.objectstyle.cayenne.conf.ServletUtil; 12 13 import webtest.Gallery; 14 import formbean.GalleryForm; 15 16 public class SaveGalleryAction extends Action { 17 18 public ActionForward execute( 19 ActionMapping mapping, 20 ActionForm form, 21 HttpServletRequest request, 22 HttpServletResponse response) 23 throws Exception { 24 25 DataContext ctxt = 26 ServletUtil.getSessionContext(request.getSession()); 27 28 GalleryForm galleryForm = (GalleryForm) form; 29 30 Gallery aGallery = (Gallery) ctxt.createAndRegisterNewObject(Gallery.class); 31 aGallery.setGalleryName(galleryForm.getGalleryName()); 32 33 ctxt.commitChanges(); 35 36 return (mapping.findForward("success")); 37 } 38 39 } | Popular Tags |