001    /**
002     * Copyright (c) 2000-2011 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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    }