Example usage for org.apache.wicket.extensions.wizard IWizardModel next

List of usage examples for org.apache.wicket.extensions.wizard IWizardModel next

Introduction

In this page you can find the example usage for org.apache.wicket.extensions.wizard IWizardModel next.

Prototype

void next();

Source Link

Document

Increments the model to the next step.

Usage

From source file:com.antilia.web.wizard.AjaxNextButton.java

License:Apache License

@Override
protected void onClick(AjaxRequestTarget target, Form<?> form) {
    IWizardModel wizardModel = getWizardModel();
    IWizardStep step = wizardModel.getActiveStep();

    // let the step apply any state
    step.applyState();/*w w  w  . j  a v a  2s .  c  o  m*/

    if (step instanceof IValidatableStep) {
        IValidatableStep validatableStep = (IValidatableStep) step;
        if (!validatableStep.isValid()) {
            AjaxWizard ajaxWizard = findParent(AjaxWizard.class);
            target.addComponent(ajaxWizard);
            return;
        }
    }
    // if the step completed after applying the state, move the
    // model onward
    if (step.isComplete()) {
        wizardModel.next();
    } else {
        error(getLocalizer().getString("org.apache.wicket.extensions.wizard.NextButton.step.did.not.complete",
                this));
    }
}

From source file:ro.nextreports.server.web.common.misc.AjaxWizardButtonBar.java

License:Apache License

public AjaxWizardButtonBar(String id, final Wizard wizard) {
    super(id, wizard);

    addOrReplace(new AjaxWizardButton("next", wizard, "next") {
        @Override/*w  ww .j  a  va 2 s .  c  om*/
        protected void onClick(AjaxRequestTarget target, Form form) {
            IWizardModel wizardModel = getWizardModel();
            IWizardStep step = wizardModel.getActiveStep();
            // let the step apply any state step.applyState();
            // if the step completed after applying the state, move the model onward
            if (step.isComplete()) {
                wizardModel.next();
            } else {
                error(getLocalizer().getString(
                        "org.apache.wicket.extensions.wizard.NextButton.step.did.not.complete", this));
            }
            target.add(wizard);
        }

        protected void onError(AjaxRequestTarget target, Form<?> form) {
            //@todo how to get feedbackPanel only
            target.add(wizard);
        }

        public final boolean isEnabled() {
            return getWizardModel().isNextAvailable();
        }
    });

    AjaxWizardButton prevButton = new AjaxWizardButton("previous", wizard, "prev") {
        @Override
        protected void onClick(AjaxRequestTarget target, Form form) {
            getWizardModel().previous();
            target.add(wizard);
        }

        protected void onError(AjaxRequestTarget target, Form<?> form) {
            //@todo how to get feedbackPanel only
            target.add(wizard);
        }

        public final boolean isEnabled() {
            return getWizardModel().isPreviousAvailable();
        }

    };
    //no validation is done clicking previous
    prevButton.setDefaultFormProcessing(false);
    addOrReplace(prevButton);

    AjaxWizardButton cancelButton = new AjaxWizardButton("cancel", wizard, "cancel") {
        @Override
        protected void onClick(AjaxRequestTarget target, Form form) {
            //getWizardModel().cancel();
            onCancel(target);
            target.add(wizard);
        }

        protected void onError(AjaxRequestTarget target, Form<?> form) {
            //@todo how to get feedbackPanel only
            target.add(wizard);
        }

        public final boolean isEnabled() {
            return getWizardModel().isCancelVisible();
        }
    };
    //no validation is done clicking cancel
    cancelButton.setDefaultFormProcessing(false);
    addOrReplace(cancelButton);

    finishButton = new AjaxWizardFinishButton("finish", wizard);
    addOrReplace(finishButton);
}