Hi

Just one note - I just had another look at our FormValidator class - you might wonder why you won't find the method error (FormComponent fc, String resourceKey) provided in my example. The reason is, we wrapped this to provide a direct access to localized error messages in our custom FormValidator:

   /**
* Reports an error against the validatable using the given literal resource key. This means, no
    * class prefix is prepended to the resource key.
    *
    * @param fc form component against which the error is reported
    * @param resourceKey The resource key to use
    */
   @Override
   public void error (FormComponent fc, String resourceKey) {
       fc.error(fc.getLocalizer().getString(resourceKey, fc));
   }


Just calling error (Serializable message) inside your form validator implementation will of course report the error against the FormValidator and not the failing component. So make sure you call myTextFieldThatFailed.error(...) instead of error(...)

The Wizard will later test, if all contained components were successful and only advance if none of them had its FormComponent.error() method invoked.

Good luck

Matt

jackkilian wrote:
Hi Matthias,

thanks! I used error(), but the wizard didn't stop. I will check it, maybe I
use a ref-Object to call error().

regards
- jk


Matthias Keller wrote:
wolfgang.sch...@dachser.com wrote:
Hi,

when I validate the data of a WizardStep after pressing Next, I
navigate within the validate method to the WizardStep.previous()
step in the false case.

Works fine! But calling the method WizardStep.previous() works
not for the first Wizard step. That's ok, there is no previous
one.
But how can I do it right?
Hi

Not sure why you even want to call next or previous at all manually?
I'm using 1.3.5 so that may make a difference but we're just adding validators to the WizardStep which takes care of everything. We never have to manually call previous() or next() ?

We're just doing:

        add(new FormValidator() {
            public FormComponent[] getDependentFormComponents() {
                return new FormComponent[] { radioGroup, checkbox };
            }
            public void validate (Form form) {
                if (isSelected(radioGroup, radio1)) {
                    if (isChecked(checkbox)) {
                        error(checkbox, "our.error");
                    }
                }
            }
        });

Note that FormValidator is our implementation of AbstractFormValidator which is just there to provide some helper methods like the isSelected() and isChecked() plus some optimizations.
Now when the error() is called, the wizard won't go to the next step.

Matt

--
matthias.kel...@ergon.ch  +41 44 268 83 98
Ergon Informatik AG, Kleinstrasse 15, CH-8008 Zürich
http://www.ergon.ch
______________________________________________________________
e r g o n    smart people - smart software

Ergon ist im Final für den Fairnesspreis 2009 - Online-Abstimmung bis 6.
Mai 2009 unter www.fairnesspreis.ch





--
matthias.kel...@ergon.ch  +41 44 268 83 98
Ergon Informatik AG, Kleinstrasse 15, CH-8008 Zürich
http://www.ergon.ch
______________________________________________________________
e r g o n    smart people - smart software

Ergon ist im Final für den Fairnesspreis 2009 - Online-Abstimmung bis 6. Mai 2009 unter www.fairnesspreis.ch

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

Reply via email to