You could use Button.setDefaultFormProcessing(false) to turn of form validation.

From the javadoc:

        /**
         * Sets the defaultFormProcessing property. When false (default is 
true),
         * all validation and form updating is bypassed and the onSubmit method 
of
         * that button is called directly, and the onSubmit method of the parent
         * form is not called. A common use for this is to create a cancel 
button.
         *
         * @param defaultFormProcessing
         *            defaultFormProcessing
         * @return This
         */
        public final Button setDefaultFormProcessing(boolean 
defaultFormProcessing)

:)

Regards,
Sebastiaan

Pills wrote:
Hello,

I would like to put 2 buttons on a form (submit/cancel). This 2 buttons need
to be localized. I tried to override the form's onSubmit, and add one new
Button (submit) and a new subclass of Button (cancel).

My code looks like this:

[CODE]
Form form = new Form("formaddeditcurrency") {
  @Override
  protected void onSubmit() {
    // do submit (insert into db)
} };

...
form.add(new Button("submitaddedit", new StringResourceModel("submit", this,
null)));
form.add(new Button("canceladdedit", new StringResourceModel("cancel", this,
null)) {
  @Override
  public void onSubmit() {
      // do cancel
  }
});
[/CODE]

My problem is that when a user click "Cancel", the form still tried to be
submitted (and since some fields are invalid, it writes some garbage to the
Feedbackpanel). However, in markup, my cancel button is not a "submit", but
a simple "button".

How can I put several buttons on a form?

Thank you for your help ;)

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to