| ModelContextTag.java |
1 /**
2 * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3 *
4 * This library is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License as published by the Free
6 * Software Foundation; either version 2.1 of the License, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
13 */
14
15 package com.liferay.taglib.aui;
16
17 import com.liferay.taglib.util.IncludeTag;
18
19 import javax.servlet.http.HttpServletRequest;
20
21 /**
22 * <a href="ModelContextTag.java.html"><b><i>View Source</i></b></a>
23 *
24 * @author Jorge Ferrer
25 * @author Brian Wing Shun Chan
26 */
27 public class ModelContextTag extends IncludeTag {
28
29 public void setBean(Object bean) {
30 _bean = bean;
31 }
32
33 public void setModel(Class<?> model) {
34 _model = model;
35 }
36
37 protected void cleanUp() {
38 _bean = null;
39 _model = null;
40 }
41
42 protected void setAttributes(HttpServletRequest request) {
43 if (_model != null) {
44 pageContext.setAttribute("aui:model-context:bean", _bean);
45 pageContext.setAttribute("aui:model-context:model", _model);
46 }
47 else {
48 pageContext.removeAttribute("aui:model-context:bean");
49 pageContext.removeAttribute("aui:model-context::model");
50 }
51 }
52
53 private Object _bean;
54 private Class<?> _model;
55
56 }