1 18 21 package org.apache.roller.ui.authoring.struts.actions; 22 23 import javax.servlet.http.HttpServletRequest ; 24 import javax.servlet.http.HttpServletResponse ; 25 26 import org.apache.struts.action.Action; 27 import org.apache.struts.action.ActionForm; 28 import org.apache.struts.action.ActionForward; 29 import org.apache.struts.action.ActionMapping; 30 import org.apache.roller.model.BookmarkManager; 31 import org.apache.roller.model.RollerFactory; 32 import org.apache.roller.pojos.FolderData; 33 import org.apache.roller.ui.core.BasePageModel; 34 import org.apache.roller.ui.core.RollerRequest; 35 import org.apache.roller.ui.authoring.struts.formbeans.FolderFormEx; 36 import org.apache.roller.ui.core.RequestConstants; 37 38 44 public class FolderEditAction extends Action 45 { 46 public ActionForward execute( 47 ActionMapping mapping, 48 ActionForm actionForm, 49 HttpServletRequest request, 50 HttpServletResponse response) 51 throws Exception 52 { 53 RollerRequest rreq = RollerRequest.getRollerRequest(request); 54 BookmarkManager bmgr = RollerFactory.getRoller().getBookmarkManager(); 55 FolderFormEx form = (FolderFormEx)actionForm; 56 57 FolderData parentFolder = null; 58 if (null!=rreq.getFolder() && null==request.getParameter("correct")) 59 { 60 request.setAttribute("state","edit"); 63 64 FolderData fd = rreq.getFolder(); 65 form.copyFrom(fd, request.getLocale()); 66 parentFolder = fd.getParent(); 67 68 BasePageModel pageModel = new BasePageModel( 69 "folderForm.add.title", request, response, mapping); 70 pageModel.setWebsite(parentFolder.getWebsite()); 71 request.setAttribute("model", pageModel); 72 } 73 else if (null != request.getParameter("correct")) 74 { 75 request.setAttribute("state","correcting"); 77 78 String parentId = request.getParameter(RequestConstants.PARENT_ID); 79 parentFolder = bmgr.getFolder(parentId); 80 81 BasePageModel pageModel = new BasePageModel( 82 "folderForm.correct.title", request, response, mapping); 83 pageModel.setWebsite(parentFolder.getWebsite()); 84 request.setAttribute("model", pageModel); 85 } 86 else 87 { 88 request.setAttribute("state","add"); 90 91 String parentId = request.getParameter(RequestConstants.PARENT_ID); 92 parentFolder = bmgr.getFolder(parentId); 93 94 BasePageModel pageModel = new BasePageModel( 95 "folderForm.add.title", request, response, mapping); 96 pageModel.setWebsite(parentFolder.getWebsite()); 97 request.setAttribute("model", pageModel); 98 } 99 100 request.setAttribute(RequestConstants.PARENT_ID, parentFolder.getId()); 101 request.setAttribute("parentFolder", parentFolder); 102 103 return mapping.findForward("FolderForm"); 104 } 105 106 } 107 | Popular Tags |