KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > action > SaveGalleryAction


1 package action;
2
3 import javax.servlet.http.HttpServletRequest JavaDoc;
4 import javax.servlet.http.HttpServletResponse JavaDoc;
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 JavaDoc request,
22         HttpServletResponse JavaDoc response)
23         throws Exception JavaDoc {
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         // commit to the database
34
ctxt.commitChanges();
35
36         return (mapping.findForward("success"));
37     }
38
39 }
Popular Tags