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 ErrorMarkerTag extends IncludeTag {
026    
027            public void setKey(String key) {
028                    _key = key;
029            }
030    
031            public void setValue(String value) {
032                    _value = value;
033            }
034    
035            @Override
036            protected void cleanUp() {
037                    _key = null;
038                    _value = null;
039            }
040    
041            @Override
042            protected void setAttributes(HttpServletRequest request) {
043                    if (Validator.isNotNull(_key) && Validator.isNotNull(_value)) {
044                            request.setAttribute("liferay-ui:error-marker:key", _key);
045                            request.setAttribute("liferay-ui:error-marker:value", _value);
046                    }
047                    else {
048                            request.removeAttribute("liferay-ui:error-marker:key");
049                            request.removeAttribute("liferay-ui:error-marker:value");
050                    }
051            }
052    
053            private String _key;
054            private String _value;
055    
056    }