001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.taglib.ui;
016    
017    import com.liferay.portal.kernel.util.Validator;
018    import com.liferay.taglib.util.IncludeTag;
019    
020    import javax.servlet.http.HttpServletRequest;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public class WriteTag extends IncludeTag {
026    
027            public void setBean(Object bean) {
028                    _bean = bean;
029            }
030    
031            public void setProperty(String property) {
032                    _property = property;
033            }
034    
035            protected void cleanUp() {
036                    _bean = null;
037                    _property = null;
038            }
039    
040            protected String getPage() {
041                    if ((_bean == null) || Validator.isNull(_property)) {
042                            return null;
043                    }
044                    else {
045                            return _PAGE;
046                    }
047            }
048    
049            protected void setAttributes(HttpServletRequest request) {
050                    request.setAttribute("liferay-ui:write:bean", _bean);
051                    request.setAttribute("liferay-ui:write:property", _property);
052            }
053    
054            private static final String _PAGE = "/html/taglib/ui/write/page.jsp";
055    
056            private Object _bean;
057            private String _property;
058    
059    }