KickJava   Java API By Example, From Geeks To Geeks.

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


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-2005 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
17 import javax.servlet.http.HttpServletRequest JavaDoc;
18 import javax.servlet.jsp.jstl.core.ConditionalTagSupport;
19
20
21 /**
22  * @author Sameer Charles
23  * @author Fabrizio Giustina
24  * @version $Revision: 364 $ ($Author: fgiust $)
25  */

26 public class PublicOnly extends ConditionalTagSupport {
27
28     /**
29      * Stable serialVersionUID.
30      */

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

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

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

49     protected boolean condition() {
50         HttpServletRequest JavaDoc request = (HttpServletRequest JavaDoc) pageContext.getRequest();
51         String JavaDoc prev = (String JavaDoc) request.getSession().getAttribute("mgnlPreview"); //$NON-NLS-1$
52
// if (Server.isAdmin() && !Resource.showPreview((HttpServletRequest)pageContext.getRequest()))
53
if (!Server.isAdmin() || (prev != null && showInPreview)) {
54             return true;
55         }
56         return false;
57     }
58
59     /**
60      * @see javax.servlet.jsp.jstl.core.ConditionalTagSupport#release()
61      */

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