| ErrorMarkerTag.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.ui;
16
17 import com.liferay.portal.kernel.util.Validator;
18
19 import javax.servlet.http.HttpServletRequest;
20 import javax.servlet.jsp.tagext.BodyTagSupport;
21
22 /**
23 * <a href="ErrorMarkerTag.java.html"><b><i>View Source</i></b></a>
24 *
25 * @author Brian Wing Shun Chan
26 */
27 public class ErrorMarkerTag extends BodyTagSupport {
28
29 public int doStartTag() {
30 HttpServletRequest request =
31 (HttpServletRequest)pageContext.getRequest();
32
33 if (Validator.isNotNull(_key) && Validator.isNotNull(_value)) {
34 request.setAttribute("liferay-ui:error-marker:key", _key);
35 request.setAttribute("liferay-ui:error-marker:value", _value);
36 }
37 else {
38 request.removeAttribute("liferay-ui:error-marker:key");
39 request.removeAttribute("liferay-ui:error-marker:value");
40 }
41
42 return SKIP_BODY;
43 }
44
45 public void setKey(String key) {
46 _key = key;
47 }
48
49 public void setValue(String value) {
50 _value = value;
51 }
52
53 private String _key;
54 private String _value;
55
56 }