ValueChangeListener fires on page load

Hello again.

I’ve added a few changevaluelisteners to fields on my page, so that I can the contents of other fields when the listened fields change.

The only trouble is that the change listeners get fired when the page loads, which I don’t want them to do.

public class ManuscriptEdit extends AbstractEditor<Manuscript> {

    LookupField manuscriptJournal;

    LookupField manuscriptJournalVolume;

    LookupField manuscriptJournalIssue;

    LookupField manuscriptProcess;

    public void init(Map<String, Object> params) {

        manuscriptJournal.addValueChangeListener(e -> {

            // If the journal is changed then we want to set the manuscript
            // process to the new journal default.
            Journal journal = (Journal) e.getValue();
            Process process = journal.getDefaultProcess();


        manuscriptJournalVolume.addValueChangeListener(e -> {




This means that my default process gets reset every time the page loads, but weirdly enough, the JournalVolume and JournalIssue don’t seem to get set to null, even thought the instructions are executed (not sure why that is).

Am I doing this right, or should I be doing it some other way (maybe listeners on the datasources?)

If I am doing it right, then how do I stop the events from being fired until the first change is made by the user?


If I create the handlers in the ready() method then they won’t run before the page has finished loading the fields. So don’t use the init() method; override the ready() method instead.

All good!

1 Like

Hi, @ray1

yes, you’re right. The reason is that data is loaded after the init method execution and of course this process will fire your listeners.