001
014
015 package com.liferay.taglib.util;
016
017 import com.liferay.portal.kernel.servlet.taglib.DynamicIncludeUtil;
018 import com.liferay.taglib.TagSupport;
019 import com.liferay.taglib.servlet.JspWriterHttpServletResponse;
020
021 import javax.servlet.http.HttpServletRequest;
022 import javax.servlet.http.HttpServletResponse;
023 import javax.servlet.jsp.JspException;
024
025
028 public class DynamicIncludeTag extends TagSupport {
029
030 @Override
031 public int doEndTag() throws JspException {
032 DynamicIncludeUtil.include(
033 getRequest(), getResponse(), getKey(), _ascendingPriority);
034
035 return super.doEndTag();
036 }
037
038 @Override
039 public int doStartTag() {
040 if (!DynamicIncludeUtil.hasDynamicInclude(getKey())) {
041 return SKIP_BODY;
042 }
043
044 return EVAL_BODY_INCLUDE;
045 }
046
047 public boolean getAscendingPriority() {
048 return _ascendingPriority;
049 }
050
051 public String getKey() {
052 return _key;
053 }
054
055 public void setAscendingPriority(boolean ascendingPriority) {
056 _ascendingPriority = ascendingPriority;
057 }
058
059 public void setKey(String key) {
060 _key = key;
061 }
062
063 protected HttpServletRequest getRequest() {
064 return (HttpServletRequest)pageContext.getRequest();
065 }
066
067 protected HttpServletResponse getResponse() {
068 return new JspWriterHttpServletResponse(pageContext);
069 }
070
071 private boolean _ascendingPriority = true;
072 private String _key;
073
074 }