1 package org.jahia.taglibs.url; 2 3 import javax.servlet.jsp.JspException ; 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 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 getIdObject () { 43 String 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 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 getJSPopupURL () { 68 if (containerList != null) { 69 String 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 { 82 super.doEndTag(); 83 containerList = null; 84 return EVAL_PAGE; 85 } 86 87 } | Popular Tags |