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.aui;
016    
017    import com.liferay.taglib.util.IncludeTag;
018    
019    import javax.servlet.http.HttpServletRequest;
020    
021    /**
022     * @author Julio Camarero
023     * @author Jorge Ferrer
024     * @author Brian Wing Shun Chan
025     */
026    public class WorkflowStatusTag extends IncludeTag {
027    
028            public void setBean(Object bean) {
029                    _bean = bean;
030            }
031    
032            public void setId(String id) {
033                    _id = id;
034            }
035    
036            public void setModel(Class<?> model) {
037                    _model = model;
038            }
039    
040            public void setStatus(int status) {
041                    _status = status;
042            }
043    
044            public void setVersion(double version) {
045                    _version = version;
046            }
047    
048            protected void cleanUp() {
049                    _bean = null;
050                    _id = null;
051                    _model = null;
052                    _status = 0;
053                    _version = 0;
054            }
055    
056            protected String getPage() {
057                    return _PAGE;
058            }
059    
060            protected boolean isCleanUpSetAttributes() {
061                    return _CLEAN_UP_SET_ATTRIBUTES;
062            }
063    
064            protected void setAttributes(HttpServletRequest request) {
065                    Object bean = _bean;
066    
067                    if (bean == null) {
068                            bean = pageContext.getAttribute("aui:model-context:bean");
069                    }
070    
071                    Class<?> model = _model;
072    
073                    if (model == null) {
074                            model = (Class<?>)pageContext.getAttribute(
075                                    "aui:model-context:model");
076                    }
077    
078                    request.setAttribute("aui:workflow-status:bean", bean);
079                    request.setAttribute("aui:workflow-status:id", _id);
080                    request.setAttribute("aui:workflow-status:model", model);
081                    request.setAttribute(
082                            "aui:workflow-status:status", String.valueOf(_status));
083                    request.setAttribute(
084                            "aui:workflow-status:version", String.valueOf(_version));
085            }
086    
087            private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;
088    
089            private static final String _PAGE =
090                    "/html/taglib/aui/workflow_status/page.jsp";
091    
092            private Object _bean;
093            private String _id;
094            private Class<?> _model;
095            int _status;
096            private double _version;
097    
098    }