While using Java Server Faces in combination with CDI it is sometimes necessary to access a Controller by another one.

Here is the controller - named SomeController - we would like to inject into the other:

@Named
@SessionScoped
public class SomeController implements Serializable{

    private static final long serialVersionUID = -4925093660563094520L;

    // your constructors, methods, EJBs here

}

Injecting the SomeController-class into the BaseController-class:

@Named
@ViewScoped
public class BaseController implements Serializable{

    private static final long serialVersionUID = -7725667602461813040L;

    @Inject
    private SomeController someController;

    // your constructors, methods, EJBs here

}

The whole magic is done with the help of the @Inject annotation.