Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Dynamic form setting errors to formItem

    Hi,

    I have a form and three combo box items set to that form. I have to validate the form using the results coming from server side.

    I use,

    form.validateData(model,new DSCallback() {
    @Override
    public void execute(DSResponse dsResponse, Object o, DSRequest dsRequest) {
    Record record = dsResponse.getData[0];
    if (record.getFlag()) {
    comboBox.clearErrors();
    comboBox.setShowErrorIcon(true);
    comboBox.setErrors("error");
    }

    if (form.validate()) {
    SC.say("valid");
    }
    }
    });

    First time, error setting is working. But the second time errors are not setting. You can see, I clear the errors before setting new errors.

    #2
    When you call validateData(), errors are automatically applied to the form, so you should not have code that clears errors on other fields.

    Calling validate() again would also clear the error you just applied, and isn't necessary anyway.

    Comment


      #3
      Hi,

      In my case, the form is in a popup window. If form valid only i should close the popup window. If I m not calling form.validate(), the popup window always close regardless the validation.

      I even try to call form.hasErrors(), that's also didn't work.
      Last edited by AnutharshaSelvarasa; 6 Nov 2018, 21:54.

      Comment


        #4
        Sorry, that didn’t make much sense. There is no automatic behavior in form validation that would close a pop-up window. That’s your code doing that, so you need to correct it if you don’t want the pop up closed.

        Comment


          #5
          Hi,
          please help me with this. After calling validateData method, I use code like this,

          if (form.validate()) {
          setRecordValues(); // this code is for setting values to seleced record
          close();
          }

          If I don't use this "close()" method. Validations are appearing. Everthing working fine. But When use "close()" method, validations are not appearing eventhough i use close() method like above
          Last edited by AnutharshaSelvarasa; 7 Nov 2018, 00:50.

          Comment


            #6
            Hi,

            I fixed it. I called formItem.getErrors(). and it works.

            Thank you.

            Comment

            Working...
            X