KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jahia > taglibs > url > ContainerListPropertiesURLTag


1 package org.jahia.taglibs.url;
2
3 import javax.servlet.jsp.JspException JavaDoc;
4
5 import org.jahia.data.beans.ContainerListBean;
6 import org.jahia.data.containers.JahiaContainerList;
7 import org.jahia.exceptions.JahiaException;
8 import org.jahia.taglibs.container.ContainerListTag;
9
10 /**
11  * Class ContainerListPropertiesURLTag : displays the URL of the container list
12  * properties window
13  *
14  * @author Jerome Tamiotti
15  */

16 public class ContainerListPropertiesURLTag extends AbstractURLTag {
17
18     private static org.apache.log4j.Logger logger =
19         org.apache.log4j.Logger.getLogger(ContainerListPropertiesURLTag.class);
20
21     private JahiaContainerList containerList = null;
22
23     protected void init () {
24
25         if (getName() == null) {
26             ContainerListTag parent = (ContainerListTag) findAncestorWithClass(this,
27                 ContainerListTag.class);
28             if (parent != null) {
29                 containerList = parent.getContainerList();
30             }
31         } else {
32             ContainerListBean containerListBean = (ContainerListBean) pageContext.findAttribute(getName());
33             if (containerListBean != null) {
34                 containerList = containerListBean.getJahiaContainerList();
35             }
36         }
37
38     }
39
40     protected Object JavaDoc getIdObject () {
41         String JavaDoc resultURL = null;
42         if (isWithJSPopup()) {
43             resultURL = getJSPopupURL();
44         } else {
45             resultURL = getURL();
46         }
47         if ( (resultURL != null) &&
48             (resultURL.length() > 0)) {
49             return resultURL;
50         }
51         return null;
52     }
53
54     protected String JavaDoc getURL () {
55         if (containerList != null) {
56             try {
57                 return getJahiaData().gui().drawContainerListPropertiesUrl(
58                     containerList);
59             } catch (JahiaException je) {
60                 logger.error("Error during URL generation:", je);
61             }
62         }
63         return null;
64     }
65
66     protected String JavaDoc getJSPopupURL () {
67         if (containerList != null) {
68             try {
69                 String JavaDoc popupURL = getJahiaData().gui().html().
70                     drawContainerListPropertiesLauncher(containerList);
71                 if ((popupURL != null) && (!"".equals(popupURL))) {
72                     return "javascript:" + popupURL;
73                 } else {
74                     return null;
75                 }
76             } catch (JahiaException je) {
77                 logger.error("Error while generating URL : ", je);
78             }
79         }
80         return null;
81     }
82
83     public int doEndTag ()
84         throws JspException JavaDoc {
85         super.doEndTag();
86         containerList = null;
87         return EVAL_PAGE;
88     }
89
90 }
Popular Tags