What exactly is validate supposed to validate?

Closely related to the previous issue:

  • Start with an absolutely basic NumberFormatter.
  • Run the AP in the debugger.
  • Put a breakpoint on the first line in validateSettings.
  • Create a workflow with this node, and edit the config.
  • Change the number format to anything, say %.99f.
  • Hit Apply or OK.
  • The debugger breaks. Inspect the value of m_numberFormatSettings.
  • The number format has the old value %.03f not the new value %.99f.
  • Now do the same but hit Apply twice, resuming in the debugger each time. The second time round, the value is updated to the new value.

How am I supposed to write code to validate settings before saving them, if all I can see is the old value before it updates??? I can’t find anything to explain how to do that.


could you please execute the node and make that change and click ok afterwards. Do you see a msg indicating that your settings changed? If not repeat the same operation but after you entered the new value click somewhere else so the component looses it’s focus. Does that solve your problem?

Yes, the settings change when I click OK or Apply.
No, the configuration dialog is modal, so it won’t let me click anywhere else until after it’s dismissed.
Yes, if I shift focus off the node, I get a ‘configured’ message to the console.

But the problem is not whether the settings change (they do). The problem is how to access the new settings in the validateSettings() function, so I can check them. The settings don’t seem to change until after SaveSettings, which comes before validate().

My guess is:
a) it is possible to access the new settings through the argument passed to validateSettings(), but node developers never do and I don’t know how; and
b) it’s convenient to check settings in configure(), so everyone does. But that means we all routinely save invalid settings and only find they’re invalid later.


I guess you’re talking about this example code?

If so please check settings.getString(KEY_NUMBER_FOMAT); <-- this should contain the new value. Reading the java-doc of the validateSettings method might help you to understand what is going on there. If you need further help please reach out to me.



OK, that helps. So we don’t get access to the specialised settings maintained by dialogs like DataColumnSpecFilterPanel, but through the settings argument there is access to the raw values by key, presumably before they get saved. I guess that’s better than nothing.

There are perhaps 100 or more JavaDoc entries for validateSettings, so I don’t know which one you mean. The override doc in Eclipse says:

Validates the settings in the passed NodeSettings object. The specified settings should be checked for completeness and consistency. It must be possible to load a settings object validated here without any exception in the #loadValidatedSettings(NodeSettings) method. The method must not change the current settings in the model - it is supposed to just check them. If some settings are missing, invalid, inconsistent, or just not right throw an exception with a message useful to the user.

I don’t find this very helpful. Is there any sample code that might show how to do this?

In many cases it’s hard to validate settings without access to the incoming TableSpec, so is that available at this point?


to find implementation of the validateSettings method you might want to have a look into any class that inherits from SettingsModel and or any class that inherits from NodeModel.

I hope this helps.