1
2
3
4
5 package gboat2.base.view.components;
6
7 import gboat2.base.bridge.util.json.JsonUtil;
8
9 import javax.servlet.http.HttpServletRequest;
10 import javax.servlet.http.HttpServletResponse;
11
12 import org.apache.struts2.views.annotations.StrutsTag;
13 import org.apache.struts2.views.annotations.StrutsTagAttribute;
14
15 import com.opensymphony.xwork2.util.ValueStack;
16
17
18
19
20
21
22
23 @StrutsTag(
24 name = "photoAttach",
25 tldTagClass = "gboat2.base.view.jsp.PhotoAttachTag",
26 description = "创建一个照片上传控件",
27 allowDynamicAttributes=true)
28 public class PhotoAttach extends AbstractAttach{
29
30 public static final String TEMPLATE = "photo-attach";
31 public static final String JQUERYACTION = "photoAttach";
32
33 protected String width;
34 protected String height;
35 protected String attachConfig;
36 protected String uploadeds;
37
38 public PhotoAttach(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
39 super(stack, request, response);
40 }
41
42 @Override
43 protected String getDefaultTemplate() {
44 return TEMPLATE;
45 }
46
47 @Override
48 protected String getJqueryAction() {
49 return JQUERYACTION;
50 }
51
52 @Override
53 public void evaluateExtraParams() {
54 super.evaluateExtraParams();
55
56 if (width != null)
57 addParameter("width", (Integer) findValue(width, Integer.class));
58
59 if (height != null)
60 addParameter("height", (Integer) findValue(height, Integer.class));
61
62 if (attachConfig != null)
63 addParameter("attachConfig", JsonUtil.object2Json(findValue(attachConfig)));
64
65 if (uploadeds != null)
66 addParameter("uploadeds", JsonUtil.object2Json(findValue(uploadeds)));
67 }
68
69 @StrutsTagAttribute(description = "照片的宽度", type = "Integer", defaultValue = "60")
70 public void setWidth(String width) {
71 this.width = width;
72 }
73
74 @StrutsTagAttribute(description = "照片的高度", type = "Integer", defaultValue = "100")
75 public void setHeight(String height) {
76 this.height = height;
77 }
78
79 @StrutsTagAttribute(description = "照片对应的附件配置信息", type = "Object", required = true)
80 public void setAttachConfig(String attachConfig) {
81 this.attachConfig = attachConfig;
82 }
83
84 @StrutsTagAttribute(description = "已上传的照片", type = "Array")
85 public void setUploadeds(String uploadeds) {
86 this.uploadeds = uploadeds;
87 }
88
89 }