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