Bean into controller

Good morning,
I created a bean on the middleware named @Component (FtpClientHelper.NAME)
public class FtpClientHelper …

Is it correct to use it on the GUI controller?

Entering “import com.company.traspammversionetest.core.FtpClientHelper;” when I go to compile the message “error: cannot find symbol class FtpClientHelper” comes out

Hi @gpaesani,
If you want to create a bean on the core module and use it on the gui or web modules, you need to create a service.

Sometimes you may want to just create a bean. But you can only use it in the same module as it was created.

Regards.

2 Likes

good morning,
I followed the instructions given but how much on the service I perform @injection of the service at compile time I get an error message. If I delete the import directive related to the service (and therefore I cannot use the service) the compilation works correctly.example_service_import.zip (344.9 KB)

Hi,

public interface AService {
    String NAME = "testserviceimport_AService";
}
public class NewScreen extends Screen {

    @Inject
    private AServiceBean testingService;

    @Subscribe("btnInvoce")
    private void onBtnInvoceClick(Button.ClickEvent event) {
       Integer aResult = testingService.test();

    }
}

There are two mistakes in your code:

  1. You’ve injected wrong type to the screen. You should inject the AService (interface).
  2. There is no “test” method in the AService interface. You should add method declaration to the AService.java:
public interface AService {
    Integer test();
...
}
1 Like