[SOLVED] Default value not used?

Unknown
edited November 5 in Community Q&A
My operator has an Int parameter for which I set a default value (in the getParameterTypes() method):

     type = new ParameterTypeInt(PARAMETER_CHUNK_SIZE,
           I18N.getMessage(I18N.getGUIBundle(), "gui.label.rmx_LTFDataReader.parameter.chunk_size.description"), 1, Integer.MAX_VALUE, false);
     type.setDefaultValue(IndexCachedLTFExampleTable.DEFAULT_BATCH_SIZE);
     types.add(type);
...
But once the operator is instantiated in the GUI, the parameter's edit box remains empty and the GUI displays the problem "The mandatory parameter "exampleset chunk size" is undefined."  What am I doing wrong?

Answers

  • Nils_Woehler
    Nils_Woehler New Altair Community Member
    Hi,

    your right. If you use the constructor you have posted setting the default value with setDefaultValue() will not change the default value.
    This is indeed a bug that I've just fixed. To avoid the problem with your current version I would recommend you to use the ParameterType declartion this way:

    type = new ParameterTypeInt(PARAMETER_CHUNK_SIZE,
                I18N.getMessage(I18N.getGUIBundle(), "gui.label.rmx_LTFDataReader.parameter.chunk_size.description"), 1, Integer.MAX_VALUE, IndexCachedLTFExampleTable.DEFAULT_BATCH_SIZE);
          type.setOptional(false);
          types.add(type);
    Best,
    Nils