1 package gboat2.base.view.components;
2
3 import javax.servlet.http.HttpServletRequest;
4 import javax.servlet.http.HttpServletResponse;
5
6 import org.apache.commons.lang3.RandomStringUtils;
7 import org.apache.commons.lang3.StringUtils;
8 import org.apache.struts2.components.ClosingUIBean;
9 import org.apache.struts2.views.annotations.StrutsTag;
10 import org.apache.struts2.views.annotations.StrutsTagAttribute;
11
12 import com.opensymphony.xwork2.util.ValueStack;
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 @StrutsTag(
31 name = "accordionItem",
32 tldTagClass = "gboat2.base.view.jsp.AccordionItemTag",
33 description = "创建一个可折叠的面板,位于 <g2:according> 标签内")
34 public class AccordionItem extends ClosingUIBean {
35 public static final String JQUERYACTION = "accordionItem";
36 public static final String TEMPLATE_CLOSE = "accordionItem-close";
37
38 public static final String TEMPLATE = "accordionItem";
39
40 protected String onClickTopics;
41
42 public AccordionItem(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
43 super(stack, request, response);
44 }
45
46 @Override
47 public String getDefaultOpenTemplate() {
48 return TEMPLATE;
49 }
50
51 @Override
52 protected String getDefaultTemplate() {
53 return TEMPLATE_CLOSE;
54 }
55
56 @Override
57 public void evaluateExtraParams() {
58 super.evaluateExtraParams();
59
60 addParameter("jqueryaction", JQUERYACTION);
61
62 if (onClickTopics != null)
63 addParameter("onClickTopics", findString(onClickTopics));
64
65 Accordion accordion = (Accordion) findAncestor(Accordion.class);
66 if (accordion != null)
67 addParameter("header", accordion.getHeader());
68
69 if (StringUtils.isBlank(id)) {
70 this.id = "accordionItem_" + RandomStringUtils.randomNumeric(5);
71 addParameter("id", this.id);
72 }
73 }
74
75 @Override
76 @StrutsTagAttribute(description = "可折叠面板的标题(头部)")
77 public void setTitle(String title) {
78 super.setTitle(title);
79 }
80
81 @StrutsTagAttribute(name = "onClickTopics", description = "A comma delimited list of topics that published when the element is clicked", type = "String", defaultValue = "")
82 public void setOnClickTopics(String onClickTopics) {
83 this.onClickTopics = onClickTopics;
84 }
85 }