Eugene Ustimenko
Eugene Ustimenko

Reputation: 322

Wicket ajax controls update bahaviours are overlapped

I have two Wicket Ajax Update Behaviours on TextField and on AjaxButton.

textField.add(AjaxFormComponentUpdatingBehavior("onchange") {
        @Override
        protected void onUpdate(AjaxRequestTarget target) {
            onTextFieldUpdate();
        }
    });
    ajaxButton = new AjaxButton("accept"){
        @Override
        protected void onSubmit(AjaxRequestTarget target, Form form) {
            onAjaxSubmited();
        }    
    });

I have 2 processes:

Upvotes: 1

Views: 440

Answers (2)

martin-g
martin-g

Reputation: 17513

You can use AjaxRequestAttributes for both the AjaxFormComponentUpdatingBehavior and the AjaxButton. See http://wicketinaction.com/2012/07/wicket-6-javascript-improvements/.

My idea is:

  • the behavior: attributes.setThrottleSettings(some millis). This way the 'change' event will fire after 'some millis'
  • the button: attributes.getAjaxCallListeners().add(new AjaxCallListener().onBeforeSend("$('#txtField').data('suppress', true)"))
  • the behavior: attributes.getAjaxCallListeners().add(new AjaxCallListener().onPrecondition("return $('#txtField').data('suppress')"))

I hope you followed me. See https://ci.apache.org/projects/wicket/guide/7.x/guide/ajax.html#ajax_5 for more info.

Upvotes: 1

Mihir
Mihir

Reputation: 270

If I am understanding correctly then all you want is to conditionally execute the code what ever you are doing inside text field onchange. Or you could set some flag inside onchange and use it to control things inside button submit.

Just my opinion; trying to prevent change behavior on button click seems confusing. From design perspective, it seems that control flow needs to be before you do anything with the textfield.

Upvotes: 0

Related Questions