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  import com.liferay.taglib.util.IncludeTag;
19  
20  import javax.servlet.http.HttpServletRequest;
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 IncludeTag {
28  
29      public void setKey(String key) {
30          _key = key;
31      }
32  
33      public void setValue(String value) {
34          _value = value;
35      }
36  
37      protected void cleanUp() {
38          _key = null;
39          _value = null;
40      }
41  
42      protected void setAttributes(HttpServletRequest request) {
43          if (Validator.isNotNull(_key) && Validator.isNotNull(_value)) {
44              request.setAttribute("liferay-ui:error-marker:key", _key);
45              request.setAttribute("liferay-ui:error-marker:value", _value);
46          }
47          else {
48              request.removeAttribute("liferay-ui:error-marker:key");
49              request.removeAttribute("liferay-ui:error-marker:value");
50          }
51      }
52  
53      private String _key;
54      private String _value;
55  
56  }