1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.seasar.tuigwaa.plugin;
17
18 import java.io.IOException;
19
20 import javax.servlet.jsp.JspException;
21 import javax.servlet.jsp.tagext.SimpleTagSupport;
22
23 import org.seasar.tuigwaa.cms.core.CmsConstants;
24 import org.seasar.tuigwaa.cms.core.CmsRequest;
25 import org.seasar.tuigwaa.cms.core.wiki.base.WikiConfigurationFactory;
26 import org.seasar.tuigwaa.cms.core.wiki.base.WikiException;
27 import org.seasar.tuigwaa.util.TgwContext;
28
29 public class PluginTag extends SimpleTagSupport {
30
31 private String args;
32
33 private String name;
34
35 public String getArgs() {
36 return args;
37 }
38
39 public void setArgs(String args) {
40 this.args = args;
41 }
42
43 public void setName(String pluginName) {
44 this.name = pluginName;
45 }
46
47 public String getName() {
48 return name;
49 }
50
51 public void doTag() throws JspException, IOException {
52 String ret = "";
53
54 try {
55 String[] args = (getArgs() != null) ? getArgs().split(",") : null;
56 PluginRequest request = new PluginRequest(getName(), args);
57 Plugin plugin;
58 plugin = WikiConfigurationFactory.getInstance()
59 .createConfiguration().getPlugin(getName());
60
61 CmsRequest req = TgwContext.getCmsRequest();
62 req.setType(CmsConstants.OUTPUTTYPE_HTML);
63 req.setSiteName(TgwContext.getSiteName());
64
65 ret = (String)plugin.service(TgwContext.getCmsRequest(), TgwContext
66 .getCmsResponse(), request);
67 } catch (WikiException e) {
68 e.printStackTrace();
69 ret = e.toString();
70 } catch (PluginException e) {
71 e.printStackTrace();
72 ret = e.toString();
73 }
74 getJspContext().getOut().write(ret);
75 }
76 }