1 package org.jahia.taglibs.url; 2 3 import javax.servlet.jsp.JspException ; 4 5 import org.jahia.data.beans.ContainerBean; 6 import org.jahia.data.containers.JahiaContainer; 7 import org.jahia.exceptions.JahiaException; 8 import org.jahia.taglibs.container.ContainerTag; 9 10 11 17 public class DeleteContainerURLTag extends AbstractURLTag { 18 19 private static org.apache.log4j.Logger logger = 20 org.apache.log4j.Logger.getLogger(DeleteContainerURLTag.class); 21 22 private JahiaContainer container = null; 23 24 protected void init() { 25 if (getName() == null) { 26 ContainerTag parent = (ContainerTag) findAncestorWithClass(this, 27 ContainerTag.class); 28 if (parent != null) { 29 this.container = parent.getContainer(); 30 } 31 } else { 32 ContainerBean containerBean = (ContainerBean) pageContext.findAttribute(getName()); 33 if (containerBean != null) { 34 this.container = containerBean.getJahiaContainer(); 35 } 36 } 37 } 38 39 protected Object getIdObject () { 40 String resultURL = null; 41 if (isWithJSPopup()) { 42 resultURL = getJSPopupURL(); 43 } else { 44 resultURL = getURL(); 45 } 46 if ( (resultURL != null) && 47 (resultURL.length() > 0)) { 48 return resultURL; 49 } 50 return null; 51 } 52 53 protected String getURL () { 54 if (container != null) { 55 try { 56 return getJahiaData().gui().drawDeleteContainerUrl( 57 container); 58 } catch (JahiaException je) { 59 logger.error("Error during URL generation:", je); 60 } 61 } 62 return null; 63 } 64 65 protected String getJSPopupURL () { 66 if (container != null) { 67 try { 68 String popupURL = getJahiaData().gui().html(). 69 drawDeleteContainerLauncher(container); 70 if ((popupURL != null) && (!"".equals(popupURL))) { 71 return "javascript:" + popupURL; 72 } else { 73 return null; 74 } 75 } catch (JahiaException je) { 76 logger.error("Error while generating URL : ", je); 77 } 78 } 79 return null; 80 } 81 82 public int doEndTag() throws JspException { 83 container = null; 86 return EVAL_PAGE; 87 } 88 89 90 } 91 | Popular Tags |