001    /**
002     * Copyright (c) 2000-2012 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            @Override
055            public int doEndTag() throws JspException {
056                    try {
057                            doTag(getPage(), _formName, _modelName, pageContext);
058    
059                            return EVAL_PAGE;
060                    }
061                    catch (Exception e) {
062                            throw new JspException(e);
063                    }
064            }
065    
066            public void setFormName(String formName) {
067                    _formName = formName;
068            }
069    
070            public void setModelName(String modelName) {
071                    _modelName = modelName;
072            }
073    
074            @Override
075            protected String getPage() {
076                    return _PAGE;
077            }
078    
079            private static final String _PAGE =
080                    "/html/taglib/ui/input_permissions/page.jsp";
081    
082            private static final String _TAG_CLASS =
083                    "com.liferay.portal.servlet.taglib.ui.InputPermissionsTagUtil";
084    
085            private static MethodKey _doEndTagMethodKey = new MethodKey(
086                    _TAG_CLASS, "doEndTag", String.class, String.class, String.class,
087                    PageContext.class);
088    
089            private String _formName = "fm";
090            private String _modelName = null;
091    
092    }