KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > roller > presentation > bookmarks > actions > FolderEditAction


1 /*
2  * Created on Oct 21, 2003
3  */

4 package org.roller.presentation.bookmarks.actions;
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.roller.model.BookmarkManager;
11 import org.roller.pojos.FolderData;
12 import org.roller.presentation.RollerRequest;
13 import org.roller.presentation.bookmarks.formbeans.FolderFormEx;
14
15 import java.util.LinkedList JavaDoc;
16
17 import javax.servlet.http.HttpServletRequest JavaDoc;
18 import javax.servlet.http.HttpServletResponse JavaDoc;
19
20 /**
21  * @struts.action path="/editor/folderEdit" name="folderFormEx" validate="false"
22  * @struts.action-forward name="FolderForm" path="/bookmarks/FolderForm.jsp"
23  *
24  * @author Dave Johnson
25  */

26 public class FolderEditAction extends Action
27 {
28     public ActionForward execute(
29         ActionMapping mapping,
30         ActionForm actionForm,
31         HttpServletRequest JavaDoc request,
32         HttpServletResponse JavaDoc response)
33         throws Exception JavaDoc
34     {
35         RollerRequest rreq = RollerRequest.getRollerRequest(request);
36         BookmarkManager bmgr = rreq.getRoller().getBookmarkManager();
37         FolderFormEx form = (FolderFormEx)actionForm;
38         
39         FolderData parentFolder = null;
40         if (null!=rreq.getFolder() && null==request.getParameter("correct"))
41         {
42             // If request specifies folder and we are not correcting an
43
// already submitted form then load that folder into the form.
44
request.setAttribute("state","edit");
45
46             FolderData fd = rreq.getFolder();
47             form.copyFrom(fd, request.getLocale());
48             parentFolder = fd.getParent();
49         }
50         else if (null != request.getParameter("correct"))
51         {
52             // We are correcting a previously submtted form.
53
request.setAttribute("state","correcting");
54             
55             String JavaDoc parentId = request.getParameter(RollerRequest.PARENTID_KEY);
56             parentFolder = bmgr.retrieveFolder(parentId);
57         }
58         else
59         {
60             // We are adding a new bookmark
61
request.setAttribute("state","add");
62             
63             String JavaDoc parentId = request.getParameter(RollerRequest.PARENTID_KEY);
64             parentFolder = bmgr.retrieveFolder(parentId);
65         }
66         
67         request.setAttribute(RollerRequest.PARENTID_KEY, parentFolder.getId());
68         request.setAttribute("parentFolder", parentFolder);
69         
70         return mapping.findForward("FolderForm");
71     }
72
73 }
74
Popular Tags