1
22
23 package com.liferay.taglib.ui;
24
25 import com.liferay.portal.kernel.util.JavaConstants;
26 import com.liferay.portal.kernel.util.StringPool;
27 import com.liferay.portal.kernel.util.Validator;
28 import com.liferay.taglib.util.ParamAndPropertyAncestorTagImpl;
29
30 import javax.portlet.RenderResponse;
31
32 import javax.servlet.ServletRequest;
33 import javax.servlet.jsp.JspException;
34
35
41 public class SectionTag extends ParamAndPropertyAncestorTagImpl {
42
43 public int doStartTag() throws JspException {
44 _tabsTag = (TabsTag)findAncestorWithClass(this, TabsTag.class);
45
46 if (_tabsTag == null) {
47 throw new JspException();
48 }
49
50 try {
51 ServletRequest req = pageContext.getRequest();
52
53 RenderResponse renderResponse = (RenderResponse)req.getAttribute(
54 JavaConstants.JAVAX_PORTLET_RESPONSE);
55
56 String namespace = StringPool.BLANK;
57
58 if (renderResponse != null) {
59 namespace = renderResponse.getNamespace();
60 }
61
62 String sectionParam = _tabsTag.getParam();
63 String sectionName = _tabsTag.getSectionName();
64 _sectionSelected = Boolean.valueOf(_tabsTag.getSectionSelected());
65 String sectionScroll = namespace + sectionParam + "TabsScroll";
66 String sectionRedirectParams =
67 "&scroll=" + sectionScroll + "&" + sectionParam + "=" +
68 sectionName;
69
70 _tabsTag.incrementSection();
71
72 req.setAttribute("liferay-ui:section:param", sectionParam);
73 req.setAttribute("liferay-ui:section:name", sectionName);
74 req.setAttribute("liferay-ui:section:selected", _sectionSelected);
75 req.setAttribute("liferay-ui:section:scroll", sectionScroll);
76
77 pageContext.setAttribute("sectionSelected", _sectionSelected);
78 pageContext.setAttribute("sectionParam", sectionParam);
79 pageContext.setAttribute("sectionName", sectionName);
80 pageContext.setAttribute("sectionScroll", sectionScroll);
81 pageContext.setAttribute(
82 "sectionRedirectParams", sectionRedirectParams);
83
84 if (!_tabsTag.isRefresh() || _sectionSelected.booleanValue()) {
85 if (!_tabsTag.isRefresh()) {
86 include(getStartPage());
87 }
88
89 return EVAL_BODY_INCLUDE;
90 }
91 else {
92 return EVAL_PAGE;
93 }
94 }
95 catch (Exception e) {
96 throw new JspException(e);
97 }
98 }
99
100 public int doEndTag() throws JspException {
101 try {
102 if (!_tabsTag.isRefresh() || _sectionSelected.booleanValue()) {
103 if (!_tabsTag.isRefresh()) {
104 include(getEndPage());
105 }
106
107 return EVAL_BODY_INCLUDE;
108 }
109 else {
110 return EVAL_PAGE;
111 }
112 }
113 catch (Exception e) {
114 throw new JspException(e);
115 }
116 }
117
118 public String getStartPage() {
119 if (Validator.isNull(_startPage)) {
120 return _START_PAGE;
121 }
122 else {
123 return _startPage;
124 }
125 }
126
127 public void setStartPage(String startPage) {
128 _startPage = startPage;
129 }
130
131 public String getEndPage() {
132 if (Validator.isNull(_endPage)) {
133 return _END_PAGE;
134 }
135 else {
136 return _endPage;
137 }
138 }
139
140 public void setEndPage(String endPage) {
141 _endPage = endPage;
142 }
143
144 private static final String _START_PAGE =
145 "/html/taglib/ui/section/start.jsp";
146
147 private static final String _END_PAGE = "/html/taglib/ui/section/end.jsp";
148
149 private String _startPage;
150 private String _endPage;
151 private TabsTag _tabsTag = null;
152 private Boolean _sectionSelected = Boolean.FALSE;
153
154 }