Ambiguous resolution for field @Default in Errai

PalomaAS :

I have a menu with two options, and depending on which option I choose, my application should show the RepoNavBar, or the UserNavBar. This classes are children of NavBar.

I have a CommonPage, in which there are some common components in all the project, and this class has two children RepoCommonPage and UserCommonPage, in which are declared the RepoNavBar and the UserNavBar.

The CommonPage uses classes of type ContentComponent like this:

public void setup(CommonPage<?> parentPage) { 
    ...
}

When I try to compile, I get this error:

Caused by: java.lang.RuntimeException: The following dependency problems were found: [INFO] Ambiguous resolution for field @Default com.client.local.common.ContentComponent in Class @Any @Default com.client.local.usermgt.common.UserCommonPage.

What can be wrong?

This is how I doing:

public abstract class NavBarComponent implements IsElement {

    @Templated(value = "navbar.html#navBtn")
    public static class NavBarItemComponent extends SimpleValueItemComponent<String> {...}
    ...
}
public class RepoNavBarComponent extends NavBarComponent {
     ...
}

public class UserNavBarComponent extends NavBarComponent {
     ...
}

public abstract class CommonPage<T extends ContentComponent> {
     ...
}

public class UserCommonPage<T extends ContentComponent> extends CommonPage<T>{
     ...
}

public class RepoCommonPage<T extends ContentComponent> extends CommonPage<T> { 
     ...
}

The ContentComponent is injected like this:

public class UserCommonPage<T extends ContentComponent> extends CommonPage<T>{

    protected UserNavBarComponent userNavBar;

    public UserNavBarComponent getUserNavBar() {
        return userNavBar;
    }

    @PageShown
    public void preparePageShown() {
        log.debug("Page shown");
        userNavBar.refresh();
    }
}
rbarriuso :

My bet is that UserCommonPage (as well as others like RepoCommonPage) should be abstract.

Also, if that's not enough, perhaps you need to create a third intermediate class that extends ContentComponent for each use case. For example:

 public abstract class UserCommonPage<T extends UserContentComponent> extends CommonPage<T>{

    @Inject
    protected UserNavBarComponent userNavBar;

    public UserNavBarComponent getUserNavBar() {
        return userNavBar;
    }

    @PageShown
    public void preparePageShown() {
        log.debug("Page shown");
        userNavBar.refresh();
    }
}

public class UserContentComponent extends ContentComponent{
   ...
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=82983&siteId=1