SourceCodeEditor won't allow value to be set when it's disabled

Hi,

I think I’ve found an interesting issue, when you set a SourceCodeEditor to disabled, it won’t “accept” setValue command, I mean the contents won’t be set to the control.
Steps to reproduce:

  1. Create SourceCodeEditor
  2. Disable it by using .setEnabled(false)
  3. Set the content of it by using .setValue(“somecontent”)
  4. the value won’t be set, if enable it, it will be empty as well

Expected behavior:
It should set the content value regardless of enabled/disabled state, so on “one screen” browse/edit screens users would see the contents, without the immediate ability of editing it


xml part:
                    <sourceCodeEditor id="scriptEditor"
                                      handleTabKey="true"
                                      mode="Groovy"
                                      showGutter="true"
                                      width="100%"/>
controller part:
....
    @Inject
    private SourceCodeEditor scriptEditor

....
scriptEditor.setEnabled(false)
scriptEditor.setValue(somescript)
....

Hi,

Thank you for reporting the problem. We have created a YouTrack issue, see the link on the right.

You can use setEditable instead of setEnabled for the SourceCodeEditor. The following code works well in “single screen” of an entity in my test-project.


 @Inject
    private SourceCodeEditor scriptEditor
....
Integer counter = 0;

private void initEditComponents(boolean enabled) {
        scriptEditor.setEditable(enabled);
        scriptEditor.setValue("test" + counter.toString());
        counter++;
        
        fieldGroup.setEditable(enabled);
        actionsPane.setVisible(enabled);
        lookupBox.setEnabled(!enabled);
    }
1 Like

Hi Rostislav,
thanks, this works for me as well! :slight_smile:

Cheers
Gabor

:ticket: See the following issue in our bug tracker:

https://youtrack.cuba-platform.com/issue/PL-8313