KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > taglibs > AdminOnly


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2006 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.cms.taglibs;
14
15 import info.magnolia.cms.beans.config.Server;
16 import info.magnolia.cms.util.Resource;
17
18 import javax.servlet.http.HttpServletRequest JavaDoc;
19 import javax.servlet.jsp.jstl.core.ConditionalTagSupport;
20
21
22 /**
23  * @author Sameer Charles
24  * @author Fabrizio Giustina
25  * @version $Revision $ ($Author $)
26  */

27 public class AdminOnly extends ConditionalTagSupport {
28
29     /**
30      * Stable serialVersionUID.
31      */

32     private static final long serialVersionUID = 222L;
33
34     /**
35      * Show in preview mode?
36      */

37     private boolean showInPreview;
38
39     /**
40      * Show in preview mode?
41      * @param showInPreview if <code>true</code> the content of the tag is shown in preview mode.
42      */

43     public void setShowInPreview(boolean showInPreview) {
44         this.showInPreview = showInPreview;
45     }
46
47     /**
48      * @see javax.servlet.jsp.jstl.core.ConditionalTagSupport#condition()
49      */

50     protected boolean condition() {
51         HttpServletRequest JavaDoc request = (HttpServletRequest JavaDoc) pageContext.getRequest();
52         if (Server.isAdmin() && (!Resource.showPreview(request) || showInPreview)) {
53             return true;
54         }
55         return false;
56     }
57
58     /**
59      * @see javax.servlet.jsp.jstl.core.ConditionalTagSupport#release()
60      */

61     public void release() {
62         this.showInPreview = false;
63         super.release();
64     }
65 }
66
Popular Tags