简体   繁体   中英

“A connector with id is already registered! ” in vaadin

I would like to fix the issue which is solved in this posting: Vaadin "A connector with id xy is already registered"

When I add the following code to MyUI I get an error in the getLogger() lline: "The method getLogger() from the type ConnectorTracker is not visible"

public class SomeUI extends UI {

    private ConnectorTracker tracker;

    @
    Override
    public ConnectorTracker getConnectorTracker() {
        if (this.tracker == null) {
            this.tracker = new ConnectorTracker(this) {

                @
                Override
                public void registerConnector(ClientConnector connector) {
                    try {
                        super.registerConnector(connector);
                    } catch (RuntimeException e) {
                        getLogger().log(Level.SEVERE, "Failed connector: {0}", connector.getClass().getSimpleName());
                        throw e;
                    }
                }

            };
        }

        return tracker;
    }
}

Is there a quick work around for this or any other solution how to fix the xy connector exception? I am using spring boot with vaadin 7 .

The getLogger() method is private, and you are implementing an anonymous subtype, which can only access public and protected methods. You can easily add your own getLogger to your UI subclass:

private static Logger getLogger() {
    return Logger.getLogger(SomeUI.class.getName());
}

private ConnectorTracker connectorTracker;

@Override
public ConnectorTracker getConnectorTracker() {
    if (connectorTracker == null) {
        connectorTracker = new ConnectorTracker(this) {
            @Override
            public void registerConnector(ClientConnector connector) {
                try{
                    super.registerConnector(connector);
                } catch (RuntimeException e) {
                    getLogger().log(Level.SEVERE, "OOPS!");
                    throw e;
                }
            }

        };
    }
    return connectorTracker;
}

To fix the a connector xy is already registered problem you need to check if any of your Components(Views, Layouts, Buttons, Panels, whatever...) are added to a view more than once.

So if a Layout is created with new VerticalLayout() there is no way to reuse it.

Meaning you should check all your Vaadin components and your own Views/UI-Components if they are used twice or if some of them are static.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM