Reputation: 16555
I have hml form with two input text
<input type="text" wicket:id = "query"/>
<input type="text" wicket:id= "address"/>
I need to implement choose mechanism. When someone start to write query then address should be disable and vice versa.
Upvotes: 2
Views: 7725
Reputation: 6685
Add an behavior to the query textfields that listens to onChange event. In the onEvent
method disable the address textfield and add it to the ajax request target.
See this example how to add the behavior and how to disable the other component. Keep in mind that you might add some checks if the other component has to be enabled or disabled.
queryTextField.add(new AjaxEventBehavior("onKeyUp") {
@Override
protected void onEvent(AjaxRequestTarget target) {
addressTextField.setEnabled(false);
target.add(addressTextField);
}
}
);
Upvotes: 6
Reputation: 10049
You can use:
myTextField.add(AttributeModifier.replace("readonly", "readonly"));
Of course, "readonly"
should be determined based on some criteria on your code.
Upvotes: 4
Reputation: 5857
I would add a behavior to both fields that disables/enables the other field when onKeyUp event is triggered through JavaScript.
Upvotes: 1