001    /**
002     * Copyright (c) 2000-2013 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.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            @Override
036            protected void cleanUp() {
037                    _bean = null;
038                    _property = null;
039            }
040    
041            @Override
042            protected String getPage() {
043                    if ((_bean == null) || Validator.isNull(_property)) {
044                            return null;
045                    }
046                    else {
047                            return _PAGE;
048                    }
049            }
050    
051            @Override
052            protected void setAttributes(HttpServletRequest request) {
053                    request.setAttribute("liferay-ui:write:bean", _bean);
054                    request.setAttribute("liferay-ui:write:property", _property);
055            }
056    
057            private static final String _PAGE = "/html/taglib/ui/write/page.jsp";
058    
059            private Object _bean;
060            private String _property;
061    
062    }