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.dialog.form;
 
A customized FormDialog that uses an AjaxSubmitLink to submit the button. It is IAjaxCallAware, and is a delegate for the AjaxCallListener of the submit button.

Parameters:
<T> The dialog and form model object type
 
 public abstract class AjaxFormDialog<T> extends FormDialog<T> implements IAjaxCallAware {
 
     private static final long serialVersionUID = 1L;
 
     public AjaxFormDialog(String markupId) {
         super(markupId);
     }
 
     public AjaxFormDialog(String idIModel<T> model) {
         super(idmodel);
     }
 
     public AjaxFormDialog(String idIModel<StringheaderIModel<T> model) {
         super(idheadermodel);
     }
 
     @Override
     protected AbstractLink newSubmitButton(String idIModel<T> modelForm<T> formComponent) {
         return new AjaxSubmitLink(idformComponent) {
             private static final long serialVersionUID = 1L;
 
             @Override
             protected void onInitialize() {
                 super.onInitialize();
                 add(new ButtonBehavior(..));
             }
 
             @Override
             protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
                 super.updateAjaxAttributes(attributes);
 
                 AjaxFormDialog dialog = AjaxFormDialog.this;
                 dialog.updateAjaxAttributes(thisattributes);
                 attributes.getAjaxCallListeners().add(new AjaxCallListener(new DelegatingAjaxCallListener(dialog)));
             }
 
             @SuppressWarnings("unchecked")
             @Override
             protected void onSubmit(AjaxRequestTarget targetForm<?> form) {
                 AjaxFormDialog.this.onSubmit(target, (Form<T>) form);
             }
         }.setBody(getSubmitButtonModel());
     }

    
Update the AjaxRequestAttributes of the AjaxSubmitLink.

Parameters:
submitLink the submit button
attributes ajax request attributes
 
     protected void updateAjaxAttributes(AjaxSubmitLink submitLinkAjaxRequestAttributes attributes) {
         // hook
     }
 
     @Override
     public IJavaScript onTrigger() {
         return null;
     }
 
     @Override
     public IJavaScript onBefore() {
         return null;
     }
    @Override
    public IJavaScript onSuccess() {
        // hide the dialog if the ajax call was successful
        return JQuery.$(this).call("modal""hide");
    }
    @Override
    public IJavaScript onFail() {
        return null;
    }
    @Override
    public IJavaScript precondition() {
        return null;
    }
    @Override
    public IJavaScript onAfter() {
        return null;
    }
    @Override
    public IJavaScript onComplete() {
        return null;
    }

    
Called when the submit link is clicked.

Parameters:
target ajax request target
form form being submitted
    protected abstract void onSubmit(AjaxRequestTarget targetForm<T> form);
New to GrepCode? Check out our FAQ X