KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > applications > managementtool > actions > CategoryAction


1 package org.infoglue.cms.applications.managementtool.actions;
2
3 import org.infoglue.cms.applications.common.actions.ModelAction;
4 import org.infoglue.cms.controllers.kernel.impl.simple.CategoryController;
5 import org.infoglue.cms.entities.kernel.Persistent;
6 import org.infoglue.cms.entities.management.CategoryVO;
7 import org.infoglue.cms.exception.ConstraintException;
8 import org.infoglue.cms.exception.SystemException;
9
10 /**
11  * @author Frank Febbraro (frank@phase2technology.com)
12  */

13 public class CategoryAction extends ModelAction
14 {
15     private static final long serialVersionUID = 1L;
16     
17     public static final String JavaDoc MAIN = "main";
18
19     private CategoryController controller = CategoryController.getController();
20
21     protected Persistent createModel() { return new CategoryVO(); }
22
23     public CategoryVO getCategory() { return (CategoryVO)getModel(); }
24
25     public Integer JavaDoc getCategoryId() { return getCategory().getCategoryId(); }
26     public void setCategoryId(Integer JavaDoc i) { getCategory().setCategoryId(i); }
27
28
29     public String JavaDoc doList() throws SystemException
30     {
31         setModels(controller.findRootCategories());
32         return SUCCESS;
33     }
34
35     public String JavaDoc doNew() throws SystemException
36     {
37         return SUCCESS;
38     }
39
40     public String JavaDoc doEdit() throws SystemException
41     {
42         setModel(controller.findWithChildren(getCategoryId()));
43         return SUCCESS;
44     }
45
46     public String JavaDoc doDisplayTreeForMove() throws SystemException
47     {
48         return SUCCESS;
49     }
50
51     public String JavaDoc doMove() throws SystemException
52     {
53         setModel(controller.moveCategory(getCategoryId(), getCategory().getParentId()));
54         return SUCCESS;
55     }
56
57     public String JavaDoc doSave() throws SystemException, ConstraintException
58     {
59         validateModel();
60         setModel(controller.save(getCategory()));
61         return (getCategory().isRoot())? MAIN : SUCCESS;
62     }
63
64     public String JavaDoc doDelete() throws SystemException
65     {
66         // So we have the parent and know which page to go to
67
setModel(controller.findById(getCategoryId()));
68         controller.delete(getCategoryId());
69
70         return (getCategory().getParentId() == null) ? MAIN : SUCCESS;
71     }
72
73     // Needed as part of WebworklAbstractAction
74
public String JavaDoc doExecute() throws Exception JavaDoc
75     { return SUCCESS; }
76 }
77
Popular Tags