001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.taglib.ui;
016    
017    import com.liferay.portal.kernel.util.MethodKey;
018    import com.liferay.portal.kernel.util.PortalClassInvoker;
019    import com.liferay.portal.kernel.util.StringPool;
020    import com.liferay.taglib.util.IncludeTag;
021    
022    import javax.servlet.jsp.JspException;
023    import javax.servlet.jsp.PageContext;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     * @author Wilson S. Man
028     */
029    public class InputPermissionsTag extends IncludeTag {
030    
031            public static String doTag(
032                            String formName, String modelName, PageContext pageContext)
033                    throws Exception {
034    
035                    return doTag(_PAGE, formName, modelName, pageContext);
036            }
037    
038            public static String doTag(
039                            String page, String formName, String modelName,
040                            PageContext pageContext)
041                    throws Exception {
042    
043                    Object returnObj = PortalClassInvoker.invoke(
044                            false, _doEndTagMethodKey, page, formName, modelName, pageContext);
045    
046                    if (returnObj != null) {
047                            return returnObj.toString();
048                    }
049                    else {
050                            return StringPool.BLANK;
051                    }
052            }
053    
054            public int doEndTag() throws JspException {
055                    try {
056                            doTag(getPage(), _formName, _modelName, pageContext);
057    
058                            return EVAL_PAGE;
059                    }
060                    catch (Exception e) {
061                            throw new JspException(e);
062                    }
063            }
064    
065            public void setFormName(String formName) {
066                    _formName = formName;
067            }
068    
069            public void setModelName(String modelName) {
070                    _modelName = modelName;
071            }
072    
073            protected String getPage() {
074                    return _PAGE;
075            }
076    
077            private static final String _TAG_CLASS =
078                    "com.liferay.portal.servlet.taglib.ui.InputPermissionsTagUtil";
079    
080            private static final String _PAGE =
081                    "/html/taglib/ui/input_permissions/page.jsp";
082    
083            private static MethodKey _doEndTagMethodKey = new MethodKey(
084                    _TAG_CLASS, "doEndTag", String.class, String.class, String.class,
085                    PageContext.class);
086    
087            private String _formName = "fm";
088            private String _modelName = null;
089    
090    }