1
22
23 package com.liferay.taglib.ui;
24
25 import com.liferay.portal.kernel.util.MethodInvoker;
26 import com.liferay.portal.kernel.util.MethodWrapper;
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 import org.apache.commons.logging.Log;
35 import org.apache.commons.logging.LogFactory;
36
37
44 public class InputPermissionsTag extends IncludeTag {
45
46 public static String doTag(
47 String formName, String modelName, PageContext pageContext)
48 throws Exception {
49
50 return doTag(_PAGE, formName, modelName, pageContext);
51 }
52
53 public static String doTag(
54 String page, String formName, String modelName,
55 PageContext pageContext)
56 throws Exception {
57
58 Object returnObj = null;
59
60 Thread currentThread = Thread.currentThread();
61
62 ClassLoader contextClassLoader = currentThread.getContextClassLoader();
63
64 try {
65 currentThread.setContextClassLoader(
66 PortalClassLoaderUtil.getClassLoader());
67
68 MethodWrapper methodWrapper = new MethodWrapper(
69 _TAG_CLASS, _TAG_DO_END_METHOD,
70 new Object[] {page, formName, modelName, pageContext});
71
72 returnObj = MethodInvoker.invoke(methodWrapper);
73 }
74 catch (Exception e) {
75 _log.error(e, e);
76 }
77 finally {
78 currentThread.setContextClassLoader(contextClassLoader);
79 }
80
81 if (returnObj != null) {
82 return returnObj.toString();
83 }
84 else {
85 return StringPool.BLANK;
86 }
87 }
88
89 public int doEndTag() throws JspException {
90 try {
91 doTag(getPage(), _formName, _modelName, pageContext);
92 }
93 catch (Exception e) {
94 if (e instanceof JspException) {
95 throw (JspException)e;
96 }
97 else {
98 throw new JspException(e);
99 }
100 }
101
102 return EVAL_PAGE;
103 }
104
105 public void setFormName(String formName) {
106 _formName = formName;
107 }
108
109 public void setModelName(String modelName) {
110 _modelName = modelName;
111 }
112
113 protected String getDefaultPage() {
114 return _PAGE;
115 }
116
117 private static final String _TAG_CLASS =
118 "com.liferay.portal.servlet.taglib.ui.InputPermissionsTagUtil";
119
120 private static final String _TAG_DO_END_METHOD = "doEndTag";
121
122 private static final String _PAGE =
123 "/html/taglib/ui/input_permissions/page.jsp";
124
125 private static Log _log = LogFactory.getLog(InputPermissionsTag.class);
126
127 private String _formName = "fm";
128 private String _modelName = null;
129
130 }