Uploaded image for project: 'ZK'
  1. ZK
  2. ZK-771

When using a validator on a form, support the ability to retrieve messages individually

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Normal Normal
    • 6.0.0
    • None
    • Databind 2

      Problem Statement

      At the moment you can have a validator on a form, for example:

      <groupbox form="@id('event') @validator('org.zkoss.todo.event.EventValidator')">
      

      However, when you do this there is no way to retrieve messages individually, so if you have a form you cannot place errors next to the respective component. This is the most common use case on forms, so in my opinion is essential.

      Possible solution

      When adding the invalid message like this this.addInvalidMessage(ctx, "age must be over 1"); we have an additional argument for the key:

      this.addInvalidMessage(ctx, "key", "message");
      

      We can then therefore retrieve the error message next to our respective component, for example say we want to validate the age in an intbox.

      this.addInvalidMessage(ctx, "age", "age must be > 1");
      

      Then in the zul file:

      <textbox id="txtAge" value="0" />
      <label value="@load(frm.validationmessage['age'])" visible="@load(not empty frm.validationmessages['age'])" />
      

            Unassigned Unassigned
            tmillsclare tmillsclare
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: