Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.cdlflex.ui.behavior;
 
A behavior that controls the size and type of a bootstrap button. This can be added to arbitrary components and will add css classes.
 
 public class ButtonBehavior extends CssClassNameAppender {
 
     private static final long serialVersionUID = 1L;
 
     public static final Type DEFAULT_TYPE = .;
     public static final Size DEFAULT_SIZE = .;
 
     private IModel<TypebuttonType;
     private IModel<SizebuttonSize;
 
     public ButtonBehavior() {
         this();
     }
 
     public ButtonBehavior(Type type) {
         this(Model.of(type), Model.of());
     }
 
     public ButtonBehavior(Size size) {
         this(Model.of(), Model.of(size));
     }
 
     public ButtonBehavior(Type typeSize size) {
         this(Model.of(type), Model.of(size));
     }
 
     public ButtonBehavior(IModel<TypebuttonTypeIModel<SizebuttonSize) {
         super(new ButtonCssClassNameModel(buttonTypebuttonSize));
         this. = buttonType;
         this. = buttonSize;
     }
 
     public Type getType() {
         return getButtonType().getObject();
     }

    
Set the button type (sets the object of the type model).

Parameters:
type the type to set
 
     public void setType(Type type) {
         this.getButtonType().setObject(type);
     }
 
     public Size getSize() {
         return getButtonSize().getObject();
     }

    
Set the button size (sets the object of the size model).

Parameters:
size the size to set
 
     public void setSize(Size size) {
         this.getButtonSize().setObject(size);
     }
 
     public IModel<TypegetButtonType() {
         return ;
     }
 
     public void setButtonType(IModel<TypebuttonType) {
         this. = buttonType;
     }
 
     public IModel<SizegetButtonSize() {
         return ;
     }
 
     public void setButtonSize(IModel<SizebuttonSize) {
         this. = buttonSize;
    }

    
Concatenates Type and Size css class names and any others required for rendering bootstrap buttons.
    public static class ButtonCssClassNameModel extends AbstractReadOnlyModel<String> {
        private static final long serialVersionUID = 1L;
        private IModel<TypebuttonType;
        private IModel<SizebuttonSize;
        public ButtonCssClassNameModel(IModel<TypebuttonTypeIModel<SizebuttonSize) {
            this. = buttonType;
            this. = buttonSize;
        }
        @Override
        public String getObject() {
            String size = .getObject().getCssClassName();
            String type = .getObject().getCssClassName();
            return Strings.join(" ".sizetype);
        }
    }
New to GrepCode? Check out our FAQ X