In my opinion one should always validate inputs coming from a submit even if the inputs were disabled. Using tools like firebug, one can easily change values of disabled inputs and submit those changed values. Atleast I don't know about wicket not submitting disabled inputs, though I would not expect that behavior and would not rely on it.
Best regards, Edwin Ursprüngliche Nachricht Von:[email protected] Gesendet:19. April 2016 7:18 nachm. An:[email protected] Antworten:[email protected] Betreff:Component disabled if it contains data Hello, I'm using Wicket 6, with Java 1.7. I'm new to Wicket and I would like to know what is the best way to implement the following: -I have a webpage with several input fields bound to a db table, and a submit button. - two of the fields can be empty when submitting the changes to the db. - however, if the fields are filled once, after submitting the page, the user should not be allowed anymore to change the values(even if leaves and reenters the page for the same registrations) Could you please tell me what is the best way to achieve this? What I have done so far is: - on the page load, when the wicket components are added to the page, I check if the db fields have values, and if they do, then I set the components to disabled: Component myComp = new TextField<Integer>("project", new PropertyModel<Integer>(getModelObject(), "project")); if (getModelObject().getProject() != null) myComp.setEnabled(false); dtForm.add(myComp ).add(RangeValidator.<Integer>range(0, 999999999)); - also on submit, I check if I have a value in my component and if yes, set the component to disable: if (getModelObject().getProject() != null ){ Component myComp = get("project"); if (myComp.isEnabled()){ myComp.setEnabled(false); dtForm.replace(tf); } } what bothers me is that I need to do all the validation again in the submit button, every time the submit will be pressed. Is there a better way? Thank you -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/Component-disabled-if-it-contains-data-tp4674313.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]
