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.PortalClassLoaderUtil;
27
28 import javax.servlet.http.HttpServletRequest;
29 import javax.servlet.jsp.JspTagException;
30 import javax.servlet.jsp.PageContext;
31 import javax.servlet.jsp.tagext.TagSupport;
32
33
39 public class ToggleValueTag extends TagSupport {
40
41 public static void doTag(
42 String id, PageContext pageContext, HttpServletRequest request)
43 throws Exception {
44
45 Thread currentThread = Thread.currentThread();
46
47 ClassLoader contextClassLoader = currentThread.getContextClassLoader();
48
49 try {
50 currentThread.setContextClassLoader(
51 PortalClassLoaderUtil.getClassLoader());
52
53 MethodWrapper methodWrapper = new MethodWrapper(
54 _TAG_CLASS, _TAG_DO_END_METHOD,
55 new Object[] {id, pageContext, request});
56
57 MethodInvoker.invoke(methodWrapper);
58 }
59 catch (Exception e) {
60 _log.error(e, e);
61
62 throw e;
63 }
64 finally {
65 currentThread.setContextClassLoader(contextClassLoader);
66 }
67 }
68
69 public int doEndTag() throws JspTagException {
70 try {
71 HttpServletRequest request =
72 (HttpServletRequest)pageContext.getRequest();
73
74 doTag(_id, pageContext, request);
75
76 return EVAL_PAGE;
77 }
78 catch (Exception e) {
79 throw new JspTagException(e.getMessage());
80 }
81 }
82
83 public void setId(String id) {
84 _id = id;
85 }
86
87 private static final String _TAG_CLASS =
88 "com.liferay.portal.servlet.taglib.ui.ToggleValueTagUtil";
89
90 private static final String _TAG_DO_END_METHOD = "doEndTag";
91
92 private static Log _log = LogFactoryUtil.getLog(ToggleValueTag.class);
93
94 private String _id;
95
96 }