1
19
20 package com.liferay.taglib.ui;
21
22 import com.liferay.portal.kernel.util.JavaConstants;
23 import com.liferay.portal.kernel.util.StringPool;
24 import com.liferay.portal.kernel.util.Validator;
25 import com.liferay.taglib.util.ParamAndPropertyAncestorTagImpl;
26
27 import javax.portlet.RenderResponse;
28
29 import javax.servlet.http.HttpServletRequest;
30 import javax.servlet.jsp.JspException;
31
32
38 public class SectionTag extends ParamAndPropertyAncestorTagImpl {
39
40 public int doStartTag() throws JspException {
41 _tabsTag = (TabsTag)findAncestorWithClass(this, TabsTag.class);
42
43 if (_tabsTag == null) {
44 throw new JspException();
45 }
46
47 try {
48 HttpServletRequest request =
49 (HttpServletRequest)pageContext.getRequest();
50
51 RenderResponse renderResponse =
52 (RenderResponse)request.getAttribute(
53 JavaConstants.JAVAX_PORTLET_RESPONSE);
54
55 String namespace = StringPool.BLANK;
56
57 if (renderResponse != null) {
58 namespace = renderResponse.getNamespace();
59 }
60
61 String sectionParam = _tabsTag.getParam();
62 String sectionName = _tabsTag.getSectionName();
63 _sectionSelected = Boolean.valueOf(_tabsTag.getSectionSelected());
64 String sectionScroll = namespace + sectionParam + "TabsScroll";
65 String sectionRedirectParams =
66 "&scroll=" + sectionScroll + "&" + sectionParam + "=" +
67 sectionName;
68
69 _tabsTag.incrementSection();
70
71 request.setAttribute("liferay-ui:section:param", sectionParam);
72 request.setAttribute("liferay-ui:section:name", sectionName);
73 request.setAttribute(
74 "liferay-ui:section:selected", _sectionSelected);
75 request.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 }