1
19
20 package com.liferay.taglib.ui;
21
22 import com.liferay.portal.kernel.log.Log;
23 import com.liferay.portal.kernel.log.LogFactoryUtil;
24 import com.liferay.portal.kernel.util.MethodInvoker;
25 import com.liferay.portal.kernel.util.MethodWrapper;
26 import com.liferay.portal.kernel.util.NullWrapper;
27 import com.liferay.portal.kernel.util.PortalClassLoaderUtil;
28 import com.liferay.portal.kernel.util.StringPool;
29 import com.liferay.taglib.util.IncludeTag;
30
31 import javax.servlet.jsp.JspException;
32 import javax.servlet.jsp.PageContext;
33
34
41 public class SocialBookmarkTag extends IncludeTag {
42
43 public static String doTag(
44 String type, String url, String title, String target,
45 PageContext pageContext)
46 throws Exception {
47
48 return doTag(_PAGE, type, url, title, target, pageContext);
49 }
50
51 public static String doTag(
52 String page, String type, String url, String title, String target,
53 PageContext pageContext)
54 throws Exception {
55
56 Object returnObj = null;
57
58 Thread currentThread = Thread.currentThread();
59
60 ClassLoader contextClassLoader = currentThread.getContextClassLoader();
61
62 try {
63 currentThread.setContextClassLoader(
64 PortalClassLoaderUtil.getClassLoader());
65
66 Object targetWrapper = target;
67
68 if (targetWrapper == null) {
69 targetWrapper = new NullWrapper(String.class.getName());
70 }
71
72 MethodWrapper methodWrapper = new MethodWrapper(
73 _TAG_CLASS, _TAG_DO_END_METHOD,
74 new Object[] {
75 page, type, url, title, targetWrapper, pageContext
76 });
77
78 returnObj = MethodInvoker.invoke(methodWrapper);
79 }
80 catch (Exception e) {
81 _log.error(e, e);
82 }
83 finally {
84 currentThread.setContextClassLoader(contextClassLoader);
85 }
86
87 if (returnObj != null) {
88 return returnObj.toString();
89 }
90 else {
91 return StringPool.BLANK;
92 }
93 }
94
95 public int doEndTag() throws JspException {
96 try {
97 doTag(getPage(), _type, _url, _title, _target, pageContext);
98 }
99 catch (Exception e) {
100 if (e instanceof JspException) {
101 throw (JspException)e;
102 }
103 else {
104 throw new JspException(e);
105 }
106 }
107
108 return EVAL_PAGE;
109 }
110
111 public void setType(String type) {
112 _type = type;
113 }
114
115 public void setUrl(String url) {
116 _url = url;
117 }
118
119 public void setTitle(String title) {
120 _title = title;
121 }
122
123 public void setTarget(String target) {
124 _target = target;
125 }
126
127 protected String getDefaultPage() {
128 return _PAGE;
129 }
130
131 private static final String _TAG_CLASS =
132 "com.liferay.portal.servlet.taglib.ui.SocialBookmarkTagUtil";
133
134 private static final String _TAG_DO_END_METHOD = "doEndTag";
135
136 private static final String _PAGE =
137 "/html/taglib/ui/social_bookmark/page.jsp";
138
139 private static Log _log = LogFactoryUtil.getLog(SocialBookmarkTag.class);
140
141 private String _type;
142 private String _url;
143 private String _title;
144 private String _target;
145
146 }