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.markup.html.alert;
 
A Border container that wraps markup around a bootstrap alert component. It adds all necessary DOM attributes and an optional dismiss button that allows the alert to be closed.
 
 public class Alert extends Border implements ICssClassNameProvider {
 
     private static final long serialVersionUID = 1L;
 
     private Level level;
     private boolean dismissible;
     private boolean fade;
 
     public Alert(String id) {
         this(idtrue);
     }
 
     public Alert(String idIModel<?> model) {
         this(idmodel.);
     }
 
     public Alert(String idLevel level) {
         this(idleveltrue);
     }
 
     public Alert(String idIModel<?> modelLevel level) {
         this(idmodelleveltrue);
     }
 
     public Alert(String idboolean dismissible) {
         this(id.dismissible);
     }
 
     public Alert(String idIModel<?> modelboolean dismissible) {
         this(idmodel.dismissible);
     }
 
     public Alert(String idLevel levelboolean dismissible) {
         this(idnullleveldismissible);
     }
 
     public Alert(String idIModel<?> modelLevel levelboolean dismissible) {
         super(idmodel);
         this. = level;
         this. = dismissible;
     }
 
     public Level getLevel() {
         return ;
     }
 
     public Alert setLevel(Level level) {
         this. = level;
         return this;
     }
 
     public boolean isDismissible() {
         return ;
     }
 
     public Alert setDismissible(boolean dismissible) {
         this. = dismissible;
         return this;
     }
 
     public boolean isFade() {
         return ;
     }
 
     public Alert setFade(boolean fade) {
         this. = fade;
         return this;
     }
 
    @Override
    public String getCssClassName() {
        return Strings.join(" ".getLevel().getCssClassName(), isDismissible()
            ? "alert-dismissible" : ""isFade() ? "fade in" : "");
    }
    @Override
    protected void onInitialize() {
        super.onInitialize();
        add(new CssClassNameAppender(this));
        addToBorder(newDismissButtonComponent("dismiss-button"));
    }
    @Override
    protected void onComponentTag(ComponentTag tag) {
        super.onComponentTag(tag);
        tag.put("role""alert");
    }

    
Factory method for creating the component that may dismiss the alert panel.

Parameters:
id the component id
Returns:
a new component
    protected Component newDismissButtonComponent(String id) {
        return new WebMarkupContainer(id) {
            private static final long serialVersionUID = 1L;
            @Override
            public boolean isVisible() {
                return isDismissible();
            }
        };
    }
New to GrepCode? Check out our FAQ X