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 public class UpdateContainerURLTag extends AbstractURLTag { 11 12 private static org.apache.log4j.Logger logger = 13 org.apache.log4j.Logger.getLogger(UpdateContainerURLTag.class); 14 15 private JahiaContainer container = null; 16 17 protected void init() { 18 if (getName() == null) { 19 ContainerTag parent = (ContainerTag) findAncestorWithClass(this, 20 ContainerTag.class); 21 if (parent != null) { 22 this.container = parent.getContainer(); 23 } 24 } else { 25 ContainerBean containerBean = (ContainerBean) pageContext.findAttribute(getName()); 26 if (containerBean != null) { 27 this.container = containerBean.getJahiaContainer(); 28 } 29 } 30 } 31 32 protected Object getIdObject () { 33 String resultURL = null; 34 if (isWithJSPopup()) { 35 resultURL = getJSPopupURL(); 36 } else { 37 resultURL = getURL(); 38 } 39 if ( (resultURL != null) && 40 (resultURL.length() > 0)) { 41 return resultURL; 42 } 43 return null; 44 } 45 46 protected String getURL () { 47 if (container != null) { 48 try { 49 return getJahiaData().gui().drawUpdateContainerUrl( 50 container); 51 } catch (JahiaException je) { 52 logger.error("Error during URL generation:", je); 53 } 54 } 55 return null; 56 } 57 58 protected String getJSPopupURL () { 59 if (container != null) { 60 try { 61 String popupURL = getJahiaData().gui().html(). 62 drawUpdateContainerLauncher(container); 63 if ((popupURL != null) && (!"".equals(popupURL))) { 64 return "javascript:" + popupURL; 65 } else { 66 return null; 67 } 68 } catch (JahiaException je) { 69 logger.error("Error while generating URL : ", je); 70 } 71 } 72 return null; 73 } 74 75 public int doEndTag() throws JspException { 76 super.doEndTag(); 79 container = null; 80 return EVAL_PAGE; 81 } 82 83 } 84 | Popular Tags |