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            public void setIconAlign(String iconAlign) {
031                    if (iconAlign != null) {
032                            super.setIconAlign(iconAlign.toLowerCase());
033                    }
034            }
035    
036            @Override
037            protected boolean isCleanUpSetAttributes() {
038                    return _CLEAN_UP_SET_ATTRIBUTES;
039            }
040    
041            @Override
042            protected void setAttributes(HttpServletRequest request) {
043                    super.setAttributes(request);
044    
045                    String value = getValue();
046    
047                    if (Validator.isNull(value)) {
048                            String type = getType();
049    
050                            if (type.equals("submit")) {
051                                    value = "save";
052                            }
053                            else if (type.equals("cancel")) {
054                                    value = "cancel";
055                            }
056                            else if (type.equals("reset")) {
057                                    value = "reset";
058                            }
059                    }
060    
061                    setNamespacedAttribute(request, "value", value);
062            }
063    
064            private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;
065    
066    }