Hi,
I'd like to have a feature in a form to reset the input in the form
components to the original value in the model (thus allowing the user
to "cancel" or revert all changes he has done in the textfields and so
on and instead display the original values in the backing model).
My current implementation in the form ctor is like this:
cancelButton = new Button("cancelButton") {
protected void onSubmit() {
SettingsForm.this.setModel(SettingsForm.this.getModel());
}
};
cancelButton.setDefaultFormProcessing(false);
cancelButton.setOutputMarkupId(true);
add(cancelButton);
This works but maybe there is some better way to achieve what I want?
The main problem with my implementation is that I also use a
FormComponentVisitor to install the following Ajaxbehaviour on the
FormComponents in order to only enable the cancel button (which as
default is disabled) whenever the user changes the input in a form
component. Installing the behaviour destroys the cancel functionality
for a DropDownChoice in the form (textfields/textarea still working).
I suppose that the model of the DropDownChoice is updated due to the
ajax round-trip, but why is the model of the textfields not touched?
public void formComponent(FormComponent c) {
if (! (c instanceof Button)) {
c.add(new
AjaxFormComponentUpdatingBehavior("onclick") {
protected void
onUpdate(AjaxRequestTarget target) {
cancelButton.setEnabled(true);
target.addComponent(cancelButton);
}
});
}
Any suggestions?
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wicket-user