KickJava   Java API By Example, From Geeks To Geeks.

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


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  * <p>Title: </p>
12  * <p>Description: </p>
13  * <p>Copyright: Copyright (c) 2002</p>
14  * <p>Company: Jahia Ltd</p>
15  * @author Serge Huber
16  * @version 1.0
17  */

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