Rev 1310 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1310 | Rev 1390 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | package pt.estgp.estgweb.web.tags; |
1 | package pt.estgp.estgweb.web.tags; |
2 | 2 | ||
- | 3 | import org.apache.struts.taglib.logic.ConditionalTagBase; |
|
3 | import org.apache.log4j.Logger; |
4 | import pt.estgp.estgweb.Globals; |
- | 5 | import pt.estgp.estgweb.domain.UserSessionImpl; |
|
4 | 6 | ||
5 | import javax.servlet.jsp.tagext.BodyTagSupport; |
- | |
6 | import javax.servlet.jsp.JspException; |
7 | import javax.servlet.jsp.JspException; |
7 | import javax.servlet.jsp.JspWriter; |
- | |
8 | - | ||
9 | import pt.estgp.estgweb.domain.UserSessionImpl; |
- | |
10 | import pt.estgp.estgweb.Globals; |
- | |
11 | 8 | ||
12 | public class IsNotAuthenticatedTag extends BodyTagSupport |
9 | public class IsNotAuthenticatedTag extends ConditionalTagBase |
13 | { |
10 | { |
14 | 11 | ||
15 | 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(IsNotAuthenticatedTag.class); |
- | |
16 | - | ||
17 | public int doStartTag() throws JspException |
12 | protected boolean condition() throws JspException { |
18 | { |
- | |
19 | if (go()) |
- | |
20 | return EVAL_BODY_TAG; |
- | |
21 | else |
- | |
22 | return SKIP_BODY; |
- | |
23 | } |
- | |
24 | - | ||
25 | public boolean go() |
- | |
26 | { |
- | |
27 | UserSessionImpl userSession = (UserSessionImpl) pageContext.getRequest().getAttribute(Globals.USER_SESSION_KEY); |
13 | UserSessionImpl userSession = (UserSessionImpl) pageContext.getRequest().getAttribute(Globals.USER_SESSION_KEY); |
28 | return userSession == null || userSession.getUser() == null; |
14 | return !(userSession != null && userSession.getUser() != null); |
29 | } |
- | |
30 | - | ||
31 | public int doEndTag() throws JspException |
- | |
32 | { |
- | |
33 | if (go()) |
- | |
34 | { |
- | |
35 | 1.5.0/docs/api/java/lang/String.html">String toPage = bodyContent.getString().trim(); |
- | |
36 | JspWriter writer = pageContext.getOut(); |
- | |
37 | try |
- | |
38 | { |
- | |
39 | writer.write(toPage); |
- | |
40 | } |
- | |
41 | catch (1.5.0/docs/api/java/lang/Exception.html">Exception e) |
- | |
42 | { |
- | |
43 | logger.error(e, e); |
- | |
44 | throw new JspException(e); |
- | |
45 | } |
- | |
46 | } |
- | |
47 | - | ||
48 | // Continue processing this page |
- | |
49 | return EVAL_PAGE; |
- | |
50 | } |
15 | } |
51 | 16 | ||
52 | 17 | ||
53 | } |
18 | } |