View Javadoc
1   package gboat2.base.view.components;
2   
3   import gboat2.base.view.GboatViewUtil;
4   
5   import javax.servlet.http.HttpServletRequest;
6   import javax.servlet.http.HttpServletResponse;
7   
8   import org.apache.struts2.views.annotations.StrutsTag;
9   import org.apache.struts2.views.annotations.StrutsTagAttribute;
10  
11  import com.opensymphony.xwork2.util.ValueStack;
12  
13  /**
14   * 创建一个下拉框
15   * 
16   * @date 2014年5月21日
17   * @author <a href="mailto:[email protected]">何明旺</a>
18   * @since 3.0.0-SNAPSHOT
19   */
20  @StrutsTag(
21          name="select",
22          tldTagClass="gboat2.base.view.jsp.SelectTag",
23          description="创建一个下拉框",
24          allowDynamicAttributes=true)
25  public class Select extends org.apache.struts2.components.Select {
26  
27      protected String colspan;
28      protected String groupColumns;
29      protected String labelCssClass;
30      protected String labelCssStyle;
31      protected String helpText;
32  
33      public Select(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
34          super(stack, request, response);
35      }
36  
37      @Override
38      public void evaluateExtraParams() {
39          super.evaluateExtraParams();
40          
41          if (colspan != null) {
42              addParameter("colspan", findValue(colspan, Integer.class));
43          }
44      
45          if (groupColumns != null) {
46              addParameter("groupColumns", findValue(groupColumns, Integer.class));
47          }
48          
49          if (labelCssClass != null) {
50              addParameter("labelCssClass", findString(labelCssClass));
51          }
52  
53          if (labelCssStyle != null) {
54              addParameter("labelCssStyle", findString(labelCssStyle));
55          }
56  
57          if (helpText != null) {
58              addParameter("helpText", findString(helpText));
59          }
60          
61          GboatViewUtil.addReadonlyParameter(this, request);
62      }
63      
64      @StrutsTagAttribute(description="控件所占的列数,只在水平布局的表单中才生效", type="Integer")
65      public void setColspan(String colspan) {
66          this.colspan = colspan;
67      }
68  
69      @StrutsTagAttribute(description="控件所占栅栏布局的列数,如果设置了该值,则会为控件最外层的 DIV 加上 col-sm-* 的样式类", type="Integer")
70      public void setGroupColumns(String groupColumns) {
71          this.groupColumns = groupColumns;
72      }
73  
74      @StrutsTagAttribute(description="标签的 CSS 样式类")
75      public void setLabelCssClass(String labelCssClass) {
76          this.labelCssClass = labelCssClass;
77      }
78  
79      @StrutsTagAttribute(description="标签的 CSS 样式")
80      public void setLabelCssStyle(String labelCssStyle) {
81          this.labelCssStyle = labelCssStyle;
82      }
83  
84      @StrutsTagAttribute(description="帮助文本,显示在文本框的下方")
85      public void setHelpText(String helpText) {
86          this.helpText = helpText;
87      }
88  }