001
014
015 package com.liferay.taglib.util;
016
017 import com.liferay.portal.kernel.servlet.taglib.BaseBodyTagSupport;
018 import com.liferay.portal.kernel.util.ParamUtil;
019 import com.liferay.portal.kernel.util.Validator;
020
021 import javax.servlet.http.HttpServletRequest;
022 import javax.servlet.jsp.tagext.BodyTag;
023
024
027 public class PositionTagSupport extends BaseBodyTagSupport implements BodyTag {
028
029 public String getPosition() {
030 return getPositionValue();
031 }
032
033 public boolean isPositionAuto() {
034 String position = getPosition();
035
036 if (position.equals(_POSITION_AUTO)) {
037 return true;
038 }
039 else {
040 return false;
041 }
042 }
043
044 public boolean isPositionInLine() {
045 String position = getPosition();
046
047 if (position.equals(_POSITION_INLINE)) {
048 return true;
049 }
050 else {
051 return false;
052 }
053 }
054
055 public void setPosition(String position) {
056 _position = position;
057 }
058
059 protected void cleanUp() {
060 _position = null;
061 }
062
063 protected String getPositionValue() {
064 HttpServletRequest request =
065 (HttpServletRequest)pageContext.getRequest();
066
067 String position = _position;
068
069 String fragmentId = ParamUtil.getString(request, "p_f_id");
070
071 if (Validator.isNotNull(fragmentId)) {
072 position = _POSITION_INLINE;
073 }
074
075 if (Validator.isNull(position)) {
076 position = _POSITION_AUTO;
077 }
078
079 return position;
080 }
081
082 private static final String _POSITION_AUTO = "auto";
083
084 private static final String _POSITION_INLINE = "inline";
085
086 private String _position;
087
088 }