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.link;
 
Renders a stable button, with an optional icon, which can be cached in a web browser and used at a later time.

Parameters:
<T> type of model object, if any
 
 public class BookmarkablePageButton<T> extends BookmarkablePageLink<T> {
 
     private static final long serialVersionUID = 1L;
 
     private IModel<IconTypeiconType;
     private ButtonBehavior buttonBehavior;
 
     public <P extends PageBookmarkablePageButton(String idClass<P> pageClass) {
         this(idpageClass.);
     }
 
     public <P extends PageBookmarkablePageButton(String idClass<P> pageClassPageParameters parameters) {
         this(idpageClassparameters.);
     }

    
Constructor.

Parameters:
componentId The non-null id of this component
pageClass The class of page to link to
type The type of the button, e.g. Success, Warn, Default, Menu...
<P> type of the page class
 
     public <P extends PageBookmarkablePageButton(final String componentIdfinal Class<P> pageClassfinal Type type) {
         this(componentIdpageClassnew PageParameters(), type);
     }

    
Constructor.

Parameters:
componentId The non-null id of this component
pageClass The class of page to link to
parameters The parameters to pass to the new page when the link is clicked
type The type of the button, e.g. Success, Warn, Default, Menu...
<P> type of the page class
 
     public <P extends PageBookmarkablePageButton(final String componentIdfinal Class<P> pageClass,
             final PageParameters parametersfinal Type type) {
         super(componentIdpageClassparameters);
 
         add( = new ButtonBehavior(type.));
     }

    
sets the size of the button according to the given org.cdlflex.ui.markup.css.Buttons.Size.

Parameters:
size the size of the button
Returns:
reference to the current instance
 
     public BookmarkablePageButton<T> setSize(Size size) {
         this..setSize(size);
 
         return this;
     }
 
     public BookmarkablePageButton<T> setType(Type type) {
         this..setType(type);
 
         return this;
     }
 
     public IModel<IconTypegetIconType() {
         return ;
     }

    
Sets the button's icon which will be rendered in front of the label.

Parameters:
iconType the new button icon
Returns:
this for chaining
    public BookmarkablePageButton<T> setIconType(IModel<IconTypeiconType) {
        this. = iconType;
        return this;
    }

    
Sets the button's icon which will be rendered in front of the label.

Parameters:
iconType the new button icon
Returns:
this for chaining
    public BookmarkablePageButton<T> setIconType(IconType iconType) {
        if (this. == null) {
            this. = new Model<>();
        }
        this..setObject(iconType);
        return this;
    }

    
Returns false if either the model or the underlying model object of the icon type is null.

Returns:
whether or not this button uses an icon type
    public boolean hasIconType() {
        IModel<IconTypemodel = getIconType();
        return model != null && model.getObject() != null;
    }
    @Override
    public void onComponentTagBody(MarkupStream markupStreamComponentTag openTag) {
        onBeforeComponentTagBody(markupStreamopenTag);
        super.onComponentTagBody(markupStreamopenTag);
    }

    
Called before the super-call to onComponentTagBody. Used to emit the icon and a spacer.

Parameters:
markupStream the markup stream
openTag the open tag
    protected void onBeforeComponentTagBody(MarkupStream markupStreamComponentTag openTag) {
        if (hasIconType()) {
            Tag icon = new Tag("i").attr("class"getIconType().getObject().getCssClassName());
            getResponse().write(icon.toMarkup() + "&nbsp;");
        }
    }
New to GrepCode? Check out our FAQ X