0
votes

Wicket version: 1.6.11

Suppose I have a Textfield component on a dynamic wizard page, which is Ajax enabled. When I click on that component I want to disable the 'Next' button on the wizard button bar, until the user has hit the enter key.

After trawling through the code for the various wizard classes - WizardButtonBar etc, I don't think this is possible with the standard implementation of the wizard buttons.

Just asking the question here with the possibility that someone can correct me if I'm wrong, or suggest alternatives for the above.

2

2 Answers

0
votes

Your WizardStep can use #setComplete()/#isComplete() to control whether the next button is enabled.

Use an AjaxFormComponentUpdatingBehavior on the textField, in #onUpdate() add the whole wizard to the AjaxRequestTarget, so the Wizard's button are updated.

0
votes

Well for the benefit of anyone else who needs help with this. Here's what I did. In my class which contains the TextField, I pass in the Wizard model, which holds references to various components, such as the Wizard Form. Using this I can get the default wizard button, and set it to enabled, or invisible.

    Component label = new TextField<String>("paramText", new PropertyModel<String>(model, valueProperty));

    label.add(new AjaxFormComponentUpdatingBehavior("onchange") { 

        private static final long serialVersionUID = 1L;

        @Override
        protected void onUpdate(final AjaxRequestTarget target) {
            Form wizardForm = wizardModel.getWizard().getForm();
            Button nextButton = (Button)wizardForm.getDefaultButton();
            nextButton.setVisible(false);

            target.add(nextButton);
            target.add(wizardForm);
            target.add((Wizard)wizardModel.getWizard());
            target.add(containerPanel);
        }
    });