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.aui;
016    
017    import com.liferay.portal.kernel.util.Validator;
018    import com.liferay.taglib.aui.base.BaseButtonTag;
019    
020    import javax.servlet.http.HttpServletRequest;
021    
022    /**
023     * @author Julio Camarero
024     * @author Jorge Ferrer
025     * @author Brian Wing Shun Chan
026     */
027    public class ButtonTag extends BaseButtonTag {
028    
029            @Override
030            protected boolean isCleanUpSetAttributes() {
031                    return _CLEAN_UP_SET_ATTRIBUTES;
032            }
033    
034            @Override
035            protected void setAttributes(HttpServletRequest request) {
036                    super.setAttributes(request);
037    
038                    String value = getValue();
039    
040                    if (Validator.isNull(value)) {
041                            String type = getType();
042    
043                            if (type.equals("submit")) {
044                                    value = "save";
045                            }
046                            else if (type.equals("cancel")) {
047                                    value = "cancel";
048                            }
049                            else if (type.equals("reset")) {
050                                    value = "reset";
051                            }
052                    }
053    
054                    setNamespacedAttribute(request, "value", value);
055            }
056    
057            private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;
058    
059    }