Design question : beans and fragments injected in screen controllers, hot deploy


Looking for a design advice. In the web module of my Cuba apps there are beans holding logic shared among several screens.

The problem is that injecting such bean in a screen controller does not work well with hot deploy.

If I edit the screen while the application is running, I will often have the hereunder message, even if I do not change the code of the injected bean itself.

DevelopmentException: Unable to find an instance of type 'class' named 'webEmailComposerBean' for instance of ''

It is likely due to the hot deploy mechanism that identifiies the bean as a dependency and for some reason cannot reload it properly.

I would be glad to get some hints: is it possible for the hot deploy mechanism to handle such case in the future ? Maybe I’m missing something and my design is in question.

In such case, what would be the design alternative to encapsulate logic shared among screens that would make hot deploy happy ?

Similarly, there are also static classes in the project I’m working on that are used for the same purpose, but I’m not fond of stacking statics for business logic. During a code review I stumbled upon the following code, and it raises issues in my book.

//TODO : why not a bean ?
public class OrderScreenUtils {
    private static final ScreenBuilders sb;
    private static final Messages messages;
    private static final DataManager dm;
    private static final DeliveryService deliveryService;
    private static final RoleService roleService;
    private static final UserSessionSource userSessionSource;
    private static final OrderService orderService;

    static {
        deliveryService = AppBeans.get(DeliveryService.class);
        sb = AppBeans.get(ScreenBuilders.class);
        messages = AppBeans.get(Messages.class);
        dm = AppBeans.get(DataManager.class);

And I have a similar issue with Fragments. When you inject a Fragment through its real class (because it has some logic that you want to use), Studio is raising the following message. I guess this is for the hot deploy mechanism to work properly.


So the question: in this code OrderCompletionDetailFragment is a Fragment with some logic (accessible through methods calls) I want to reuse among several screens. How can I comply with studio hint while doing so ?


Hi there,

I would be glad to have hindsights from JMIX team on this purpose.

Hot deploy is working seldomly on my project, and this is a sensible hit to productivity.