KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > nextime > ion > backoffice > action > content > WorkflowActionsTag


1 package org.nextime.ion.backoffice.action.content;
2
3 import javax.servlet.jsp.JspException JavaDoc;
4 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
5
6 import org.apache.taglibs.standard.lang.support.ExpressionEvaluatorManager;
7
8 import org.nextime.ion.framework.business.Publication;
9 import org.nextime.ion.framework.business.User;
10 import org.nextime.ion.framework.mapping.Mapping;
11
12 public class WorkflowActionsTag extends TagSupport JavaDoc {
13
14     protected String JavaDoc var;
15     protected String JavaDoc publication;
16     protected String JavaDoc user;
17     protected String JavaDoc version;
18
19     public int doStartTag() throws JspException JavaDoc {
20         evaluateExpressions();
21         try {
22             Mapping.begin();
23             pageContext.setAttribute(
24                 var,
25                 Publication
26                     .getInstance(publication)
27                     .getVersion(Integer.parseInt(getVersion()))
28                     .getWorkflow(User.getInstance(user))
29                     .getAvailableActions());
30         } catch (Exception JavaDoc e) {
31             throw new JspException JavaDoc(e);
32         } finally {
33             Mapping.rollback();
34         }
35         return (EVAL_BODY_INCLUDE);
36     }
37
38     public int doEndTag() throws JspException JavaDoc {
39         return (EVAL_PAGE);
40     }
41
42     private void evaluateExpressions() throws JspException JavaDoc {
43         if (user != null) {
44             user =
45                 ExpressionEvaluatorManager.evaluate(
46                     "user",
47                     user,
48                     Object JavaDoc.class,
49                     this,
50                     pageContext)
51                     + "";
52         }
53         if (publication != null) {
54             publication =
55                 ExpressionEvaluatorManager.evaluate(
56                     "publication",
57                     publication,
58                     Object JavaDoc.class,
59                     this,
60                     pageContext)
61                     + "";
62         }
63         if (version != null) {
64             version =
65                 ExpressionEvaluatorManager.evaluate(
66                     "version",
67                     version,
68                     Object JavaDoc.class,
69                     this,
70                     pageContext)
71                     + "";
72         }
73     }
74
75     /**
76      * Returns the publication.
77      * @return String
78      */

79     public String JavaDoc getPublication() {
80         return publication;
81     }
82
83     /**
84      * Returns the user.
85      * @return String
86      */

87     public String JavaDoc getUser() {
88         return user;
89     }
90
91     /**
92      * Returns the var.
93      * @return String
94      */

95     public String JavaDoc getVar() {
96         return var;
97     }
98
99     /**
100      * Sets the publication.
101      * @param publication The publication to set
102      */

103     public void setPublication(String JavaDoc publication) {
104         this.publication = publication;
105     }
106
107     /**
108      * Sets the user.
109      * @param user The user to set
110      */

111     public void setUser(String JavaDoc user) {
112         this.user = user;
113     }
114
115     /**
116      * Sets the var.
117      * @param var The var to set
118      */

119     public void setVar(String JavaDoc var) {
120         this.var = var;
121     }
122
123     /**
124      * Returns the version.
125      * @return String
126      */

127     public String JavaDoc getVersion() {
128         return version;
129     }
130
131     /**
132      * Sets the version.
133      * @param version The version to set
134      */

135     public void setVersion(String JavaDoc version) {
136         this.version = version;
137     }
138
139 }
140
Popular Tags