Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Wrong error message when form is validated
Wrong error message when form is validated [message #1271072] Fri, 14 March 2014 07:20 Go to next message
Fredrik Möller is currently offline Fredrik Möller
Messages: 14
Registered: April 2013
Junior Member
In my application there is an AbstractTableField with the columns defined as displayed by the screenshot:

index.php/fa/17731/0/

When I try to save the form i get an error as displayed in the screenshot.

Code setup:
The Gleisgruppe column is configured as Mandatory as below:

@Override
protected boolean getConfiguredMandatory() {
  return true;
} 


Besides from this I do have a custom validation that checks that the value in the Gleisgruppe column do not occur more than once.

In my scenario I would expect my custom error message rather than the "Mandatory" error message

Is this a known problem, that if you set the error status of the Cell object of the column with the following code, you will end up with the "Mandatory error message" and not your own error message.

IProcessingStatus status = new ProcessingStatus("Gleisgruppe already configured in another Fahrzeit", ProcessingStatus.ERROR);
rowFromTable.getCellForUpdate(gleisGruppeColumn).setErrorStatus(status);


Kind regards
Fredrik Möller

[Updated on: Fri, 14 March 2014 07:21]

Report message to a moderator

Re: Wrong error message when form is validated [message #1271170 is a reply to message #1271072] Fri, 14 March 2014 12:24 Go to previous messageGo to next message
Fredrik Möller is currently offline Fredrik Möller
Messages: 14
Registered: April 2013
Junior Member
Hello!

I have debugged a little and it looks like the following section of code from the class: org.eclipse.scout.rt.client.ui.form.AbstractForm

 @Override
  public void validateForm() throws ProcessingException {
    m_currentValidateContentDescriptor = null;
    if (!execCheckFields()) {
      VetoException veto = new VetoException("Validate " + getClass().getSimpleName());
      veto.consume();
      throw veto;
    }
    if (!getHandler().onCheckFields()) {
      VetoException veto = new VetoException("Validate " + getClass().getSimpleName());
      veto.consume();
      throw veto;
    }
    // check all fields that might be invalid
    final ArrayList<String> invalidTexts = new ArrayList<String>();
    final ArrayList<String> mandatoryTexts = new ArrayList<String>();
    P_AbstractCollectingFieldVisitor<IValidateContentDescriptor> v = new P_AbstractCollectingFieldVisitor<IValidateContentDescriptor>() {
      @Override
      public boolean visitField(IFormField f, int level, int fieldIndex) {
        IValidateContentDescriptor desc = f.validateContent();
        if (desc != null) {
          if (desc.getErrorStatus() != null) {
            invalidTexts.add(desc.getDisplayText() + ": " + desc.getErrorStatus().getMessage());
          }
          else {
            mandatoryTexts.add(desc.getDisplayText());
          }
          if (getCollectionCount() == 0) {
            collect(desc);
          }
        }
        return true;
      }
    };


is involved. The IValidateContentDescriptor in use in my scenario is the following: org.eclipse.scout.rt.client.ui.form.fields.tablefield.ValidateTableFieldDescriptor and this has the following implementation of the getErrorStatus method is:

@Override
  public IProcessingStatus getErrorStatus() {
    return null;
  }


That would problably explain the incorrect errormessage.

[Updated on: Fri, 14 March 2014 12:24]

Report message to a moderator

Re: Wrong error message when form is validated [message #1271196 is a reply to message #1271170] Fri, 14 March 2014 13:28 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 704
Registered: October 2011
Senior Member
I am not sure if by default, the TableField contributes error messages to the form for each invalid row.

Without seeing your code, it is hard to tell. It seems you have a solution by now.

Is it Ok or have you more questions?

Re: Wrong error message when form is validated [message #1272147 is a reply to message #1271196] Mon, 17 March 2014 07:18 Go to previous message
Fredrik Möller is currently offline Fredrik Möller
Messages: 14
Registered: April 2013
Junior Member
Hello Jeremie

I have something like this in my code:

if (triggerForErrorMessage) {
  IProcessingStatus status = new ProcessingStatus("Error message to display", ProcessingStatus.ERROR);
  tableRow.getCellForUpdate(table.getColumn().getColumnIndex()).setErrorStatus(status);
}


Tbhe above code works for all other column types than the Boolean one. The problem is that the IValidateContentDescriptor in use allways returns null...

I could problably override this behaviour by replacing some Scout out of the box classes, but if possible I would rather like to avoid that.

I cannot see why the boolean column allways should return null as error status, especially when the API allows you to set an error status. It took me som while to find this out, and it looks like an API inconsistence for me?
Previous Topic:An AbstractBooleanColumn does never display the icon AbstractIcons.StatusError?
Next Topic:EventHandler and ClientSession
Goto Forum:
  


Current Time: Tue Sep 23 08:23:28 GMT 2014

Powered by FUDForum. Page generated in 0.02271 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software