Example usage for org.apache.wicket.markup.html.form Form getWebPage

List of usage examples for org.apache.wicket.markup.html.form Form getWebPage

Introduction

In this page you can find the example usage for org.apache.wicket.markup.html.form Form getWebPage.

Prototype

public final WebPage getWebPage() 

Source Link

Document

A convenience method to return the WebPage.

Usage

From source file:nl.knaw.dans.common.wicket.behavior.FormModificationDetectorBehavior.java

License:Apache License

public void bind(Component component) {
    if (!(component instanceof Form)) {
        throw new WicketRuntimeException(getClass() + " behavior can be bound only to a Form component");
    }/* w  ww .  j a v a 2  s  . co  m*/
    Form form = (Form) component;

    // This will make sure that the Form emits the
    // HTML 'ID' attribure when rendering. We require the 'ID' in our JS file

    form.setOutputMarkupId(true);

    // Since we require the Form "id" and the 'message' in our JavaScript
    // template, we will use Wicket's TextTemplateHeaderContributor that allows us to
    // perform variable substitutions at runtime. Keep the JS file in the same package location
    // as the behavior.

    // load dependencies
    form.getWebPage().add(JavascriptPackageResource.getHeaderContribution(WicketEventReference.INSTANCE));
    form.getWebPage().add(JavascriptPackageResource.getHeaderContribution(WicketAjaxReference.INSTANCE));

    form.getWebPage().add(TextTemplateHeaderContributor.forJavaScript(FormModificationDetectorBehavior.class,
            "j-script/FormModificationDetector.js", new FormModificationDetectorModel(form.getMarkupId())));
}

From source file:nl.knaw.dans.dccd.common.web.behavior.FormModificationDetectorBehavior.java

License:Apache License

public void bind(Component component) {
    if (!(component instanceof Form)) {
        throw new WicketRuntimeException(getClass() + " behavior can be bound only to a Form component");
    }//from w w w  .jav  a2s.c  o  m
    Form form = (Form) component;

    // This will make sure that the Form emits the
    // HTML 'ID' attribure when rendering. We require the 'ID' in our JS file

    form.setOutputMarkupId(true);

    // Since we require the Form "id" and the 'message' in our JavaScript
    // template, we will use Wicket's TextTemplateHeaderContributor that allows us to
    // perform variable substitutions at runtime. Keep the JS file in the same package location
    // as the behavior.

    // TODO needed after continue deposit from dataset view page. (but why?)
    form.getWebPage().add(HeaderContributor.forJavaScript(AbstractDefaultAjaxBehavior.class, "wicket-ajax.js"));

    form.getWebPage().add(TextTemplateHeaderContributor.forJavaScript(FormModificationDetectorBehavior.class,
            "j-script/FormModificationDetector.js", new FormModificationDetectorModel(form.getMarkupId())));
}