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.ajax.markup.html.form;
 
 import static org.rauschig.wicketjs.jquery.JQuery.$;
 
An AjaxSubmitLink that uses bootstrap's button JavaScript to load a default loading text.

 
 public abstract class IndicatingSubmitButton extends AjaxSubmitLink implements IAjaxCallAware {
     private static final long serialVersionUID = 1L;
 
     private IModel<StringloadingDisplayModel;
 
     public IndicatingSubmitButton(String id) {
         super(id);
     }
 
     public IndicatingSubmitButton(String idForm<?> form) {
         super(idform);
     }
 
     public IndicatingSubmitButton(String idForm<?> formIModel<StringloadingDisplayModel) {
         super(idform);
         this. = loadingDisplayModel;
     }

    
Sets the model used for showing the loading text.

Parameters:
model a string model
Returns:
this for chaining
 
         this. = model;
         return this;
     }

    
Returns the model used for showing the loading text.

Returns:
a string model
 
     public IModel<StringgetLoadingDisplayModel() {
         return ;
     }
 
     @Override
     public IJavaScript onTrigger() {
         return null;
     }
 
     @Override
     public IJavaScript onBefore() {
         return null;
     }
 
     @Override
     public IJavaScript onSuccess() {
         return null;
     }
 
     @Override
     public IJavaScript onFail() {
         return null;
     }
 
     @Override
     public IJavaScript precondition() {
         return null;
     }
 
     @Override
     public IJavaScript onAfter() {
        return null;
    }
    @Override
    public IJavaScript onComplete() {
        return null;
    }
    @Override
    protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
        super.updateAjaxAttributes(attributes);
        attributes.getAjaxCallListeners().add(new AjaxCallListener(new JsAjaxCallListener() {
            private static final long serialVersionUID = 1L;
            @Override
            public IJavaScript getBeforeHandler(Component component) {
                return $(component).call("button""loading");
            }
            @Override
            public IJavaScript getCompleteHandler(Component component) {
                return $(component).call("button""reset");
            }
        }));
        attributes.getAjaxCallListeners().add(new AjaxCallListener(new DelegatingAjaxCallListener(this)));
    }
    @Override
    protected void onComponentTag(ComponentTag tag) {
        super.onComponentTag(tag);
        String loadingText = getLoadingText();
        if (loadingText != null) {
            tag.put("data-loading-text"loadingText);
        }
    }

    
Loads the model object from the loadingDisplayModel.

Returns:
a string to show as loading text
    private String getLoadingText() {
        IModel<Stringmodel = getLoadingDisplayModel();
        if (model == null) {
            return null;
        }
        return model.getObject();
    }
New to GrepCode? Check out our FAQ X