1 31 32 package org.opencms.jsp; 33 34 import org.opencms.flex.CmsFlexController; 35 import org.opencms.main.CmsLog; 36 import org.opencms.main.OpenCms; 37 import org.opencms.staticexport.CmsLinkManager; 38 39 import javax.servlet.ServletRequest ; 40 import javax.servlet.jsp.JspException ; 41 import javax.servlet.jsp.tagext.BodyTagSupport ; 42 43 import org.apache.commons.logging.Log; 44 45 57 public class CmsJspTagLink extends BodyTagSupport { 58 59 60 private static final long serialVersionUID = -2361021288258405388L; 61 62 63 private static final Log LOG = CmsLog.getLog(CmsJspTagLink.class); 64 65 76 public static String linkTagAction(String link, ServletRequest req) { 77 78 CmsFlexController controller = CmsFlexController.getController(req); 79 if (link.indexOf(':') >= 0) { 80 return OpenCms.getLinkManager().substituteLink(controller.getCmsObject(), link); 81 } else { 82 return OpenCms.getLinkManager().substituteLink( 83 controller.getCmsObject(), 84 CmsLinkManager.getAbsoluteUri(link, controller.getCurrentRequest().getElementUri())); 85 } 86 } 87 88 93 public int doEndTag() throws JspException { 94 95 ServletRequest req = pageContext.getRequest(); 96 97 if (CmsFlexController.isCmsRequest(req)) { 99 try { 100 String link = getBodyContent().getString(); 102 getBodyContent().clear(); 103 String newlink = linkTagAction(link, req); 105 getBodyContent().print(newlink); 107 getBodyContent().writeOut(pageContext.getOut()); 108 109 } catch (Exception ex) { 110 if (LOG.isErrorEnabled()) { 111 LOG.error(Messages.get().getBundle().key(Messages.ERR_PROCESS_TAG_1, "link"), ex); 112 } 113 throw new JspException (ex); 114 } 115 } 116 return EVAL_PAGE; 117 } 118 } 119 | Popular Tags |