It sounds like that, in addition to the behavior, you also need a wicket validator.
Since the validation condition involves two fields, you'll need to implement an IFormValidator and add it to the containing form [1]. The #getDependentComponents() method should return the two textfields. In the #validate(Form) method, you'll want to get the converted input from the two components and check that they're both null/empty or both not null/not empty [2]. The reason you need to use the converted input on the form component, not the model, is that Wicket doesn't update the backing model until the form is valid. Andrew [1] https://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/wicket/markup/html/form/validation/IFormValidator.html [2] https://ci.apache.org/projects/wicket/apidocs/6.x/org/apache/wicket/markup/html/form/FormComponent.html#getConvertedInput() On Wed, Apr 20, 2016 at 4:09 AM, Iamuser <[email protected]> wrote: > Hello, > > Thank you all for the help. > > Is there a way to only rerender the two components (inputtext fields) and > not all the page? > > So submit should remain like this: > > @Override > protected void onSubmit() { > //other stuff > } > > The logic is that I should be able to commit changes only if both input > textfields are filled with data, or if both are empty. If both have data, > then components should become disabled, if both are empty, then the > components should remain editable, if only one of them has data then I > should not be let to submit any change. > > > > > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/Component-disabled-if-it-contains-data-tp4674313p4674321.html > Sent from the Users forum mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
