1
14
15 package com.liferay.taglib.aui;
16
17 import com.liferay.portal.kernel.util.Validator;
18 import com.liferay.taglib.util.IncludeTag;
19 import com.liferay.util.PwdGenerator;
20
21 import java.util.ArrayList;
22 import java.util.List;
23
24 import javax.servlet.http.HttpServletRequest;
25
26
32 public class PanelTag extends IncludeTag {
33
34 public void addToolTag(ToolTag toolTag) {
35 if (_toolTags == null) {
36 _toolTags = new ArrayList<ToolTag>();
37 }
38
39 _toolTags.add(toolTag);
40 }
41
42 public List<ToolTag> getToolTags() {
43 return _toolTags;
44 }
45
46 public void setCollapsible(boolean collapsible) {
47 _collapsible = collapsible;
48 }
49
50 public void setId(String id) {
51 _id = id;
52 }
53
54 public void setLabel(String label) {
55 _label = label;
56 }
57
58 protected void cleanUp() {
59 _collapsible = false;
60 _id = null;
61 _label = null;
62
63 if (_toolTags != null) {
64 for (ToolTag toolTag : _toolTags) {
65 toolTag.cleanUp();
66 }
67
68 _toolTags = null;
69 }
70 }
71
72 protected String getEndPage() {
73 return _END_PAGE;
74 }
75
76 protected String getStartPage() {
77 return _START_PAGE;
78 }
79
80 protected boolean isCleanUpSetAttributes() {
81 return _CLEAN_UP_SET_ATTRIBUTES;
82 }
83
84 protected void setAttributes(HttpServletRequest request) {
85 String id = _id;
86
87 if (Validator.isNull(id)) {
88 id = PwdGenerator.getPassword(PwdGenerator.KEY3, 4);
89 }
90
91 request.setAttribute(
92 "aui:panel:collapsible", String.valueOf(_collapsible));
93 request.setAttribute("aui:panel:id", id);
94 request.setAttribute("aui:panel:label", _label);
95 request.setAttribute("aui:panel:toolTags", _toolTags);
96 }
97
98 private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;
99
100 private static final String _END_PAGE = "/html/taglib/aui/panel/end.jsp";
101
102 private static final String _START_PAGE =
103 "/html/taglib/aui/panel/start.jsp";
104
105 private boolean _collapsible;
106 private String _id;
107 private String _label;
108 private List<ToolTag> _toolTags;
109
110 }