Rev 1782 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
207 | jmachado | 1 | package pt.estgp.estgweb.web.tags; |
2 | |||
3 | import org.apache.log4j.Logger; |
||
4 | |||
5 | import javax.servlet.jsp.tagext.BodyTagSupport; |
||
6 | import javax.servlet.jsp.JspException; |
||
7 | import javax.servlet.jsp.JspWriter; |
||
8 | |||
9 | import pt.estgp.estgweb.domain.UserSessionImpl; |
||
10 | import pt.estgp.estgweb.domain.UserImpl; |
||
1814 | jmachado | 11 | import pt.estgp.estgweb.utils.Globals; |
207 | jmachado | 12 | |
13 | public class IsStudentOfCourseUnitTag extends BodyTagSupport |
||
14 | { |
||
15 | |||
16 | private static final 1.5.0/docs/api/java/util/logging/Logger.html">Logger logger = 1.5.0/docs/api/java/util/logging/Logger.html">Logger.getLogger(IsStudentOfCourseUnitTag.class); |
||
17 | |||
18 | |||
19 | private long courseUnitId; |
||
20 | |||
21 | public long getCourseUnitId() |
||
22 | { |
||
23 | return courseUnitId; |
||
24 | } |
||
25 | |||
26 | public void setCourseUnitId(long courseUnitId) |
||
27 | { |
||
28 | this.courseUnitId = courseUnitId; |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * |
||
33 | * @return |
||
34 | * @throws javax.servlet.jsp.JspException |
||
35 | */ |
||
36 | public int doStartTag() throws JspException |
||
37 | { |
||
38 | if (go()) |
||
39 | { |
||
40 | return EVAL_BODY_BUFFERED; |
||
41 | } |
||
42 | else |
||
43 | return SKIP_BODY; |
||
44 | |||
45 | } |
||
46 | |||
47 | public boolean go() |
||
48 | { |
||
49 | UserSessionImpl userSession = (UserSessionImpl) pageContext.getRequest().getAttribute(Globals.USER_SESSION_KEY); |
||
1782 | jmachado | 50 | return userSession != null && userSession.getUser() != null && ((UserImpl)((userSession.getUser()))).checkIsStudentfCourseUnit(courseUnitId); |
207 | jmachado | 51 | } |
52 | |||
53 | public int doEndTag() throws JspException |
||
54 | { |
||
55 | |||
56 | if (go()) |
||
57 | { |
||
58 | 1.5.0/docs/api/java/lang/String.html">String toPage = bodyContent.getString().trim(); |
||
59 | JspWriter writer = pageContext.getOut(); |
||
60 | try |
||
61 | { |
||
62 | writer.write(toPage); |
||
63 | } |
||
64 | catch (1.5.0/docs/api/java/lang/Exception.html">Exception e) |
||
65 | { |
||
66 | logger.error(e, e); |
||
67 | throw new JspException(e); |
||
68 | } |
||
69 | } |
||
70 | |||
71 | // Continue processing this page |
||
72 | return EVAL_PAGE; |
||
73 | } |
||
74 | |||
75 | |||
76 | } |