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 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 getIdObject () { 41 String 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 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 getJSPopupURL () { 67 if (containerList != null) { 68 try { 69 String 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 { 85 super.doEndTag(); 86 containerList = null; 87 return EVAL_PAGE; 88 } 89 90 } | Popular Tags |