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 CssClassNameAppender is an AttributeAppender that appends given strings to the class html attribute. It keeps classes unique within one attribute, making the operation idempotent.

Example:
The markup

 <span class="className" wicket:id="foo">
 
Using the following CssClassNameAppenders
 label.add(new CssClassNameAppender("className2", "className3"));
 label.add(new CssClassNameAppender("className2"));
 
will yield
 <span class="className className2 className3" wicket:id="foo" >
 
(Not necessarily in that order)
 
 public class CssClassNameAppender extends AttributeAppender {
 
     private static final long serialVersionUID = 1L;

    
The name of the html class attribute name.
 
     public static final String ATTRIBUTE_NAME = "class";
 
     public CssClassNameAppender(String value) {
         this(, Model.of(value), " ");
     }
 
     public CssClassNameAppender(String... values) {
         this(Strings.join(" ", (Object[]) values));
     }
 
     public CssClassNameAppender(IModel<?> replaceModel) {
         this(replaceModel" ");
     }
 
     public <T extends ICssClassNameProvider & SerializableCssClassNameAppender(T cssClassNameProvider) {
         this(new CssClassNameProvidingModel<>(cssClassNameProvider));
     }
 
     protected CssClassNameAppender(String attributeIModel<?> appendModelString separator) {
         super(attributeappendModelseparator);
     }
 
     @Override
     protected String newValue(String currentValueString appendValue) {
         return Strings.unique(getSeparator(), currentValueappendValue);
     }

    
Appends the given CSS classes to the given ComponentTag. It preserves the class attributes set in the ComponentTag. CSS classes are never duplicated.

Parameters:
tag the component tag
cssClasses the classes to append
 
     public static void append(ComponentTag tagString... cssClasses) {
         String currentValue = tag.getAttribute("class");
         String appendValue = Strings.join(" ", (Object[]) cssClasses);
 
         tag.put("class", Strings.unique(" "currentValueappendValue));
     }

    
Appends the css class the given ICssClassNameProvider provides to the given COmponentTag. It preserves the class attributes set in the ComponentTag. CSS classes are never duplicated.

Parameters:
tag the component tag
classNameProvider the class name provider
    public static void append(ComponentTag tagICssClassNameProvider classNameProvider) {
        append(tagclassNameProvider.getCssClassName());
    }

    
Appends the css class the given ICssClassNameProvider provides to the given COmponentTag. It preserves the class attributes set in the ComponentTag. CSS classes are never duplicated.

Parameters:
tag the component tag
classNameProvider the class name provider
    public static void append(ComponentTag tagIModel<? extends ICssClassNameProviderclassNameProvider) {
        append(tagclassNameProvider.getObject());
    }
New to GrepCode? Check out our FAQ X