Errai: The browser as a platform

Friday, January 11, 2013

Implicitly @Dependent. Explicitly Awesome!

One common problem that keeps catching people off guard using Errai UI and its hip companion framework, Errai UI Navigation, has been that @Templated and @Page beans have required explicit-scoping in order to work correctly.

It turns out that you almost always want such beans to be of the @Dependent scope. But if you know a little bit about CDI, you might be saying to yourself: well, all non-explicitly scoped beans are of the @Dependent scope! 

Well, yes. This is true. But Errai throws a bit of a curve-ball here. Because while Errai respects this semantic when it comes to static injection, it does not respect it when it comes to dynamic injection / dynamic lookup.

The reason for this is straight-forward. When Errai compiles your CDI code magically down to JavaScript (via the GWT compiler), it prunes all the bean wiring code from non-explicitly scoped beans. It does this as a way of minimizing the amount of dead code that ends up being compiled. 

So, for example, if we respected the CDI specification strictly, we'd end up having to create bean wiring code for things like ArrayList, HashMap, LinkedList, StringBuilder, etc.  Instead, we allow you to @Inject those dependent beans directly as you might in a fully compliant CDI container. But we don't produce the code to allow them to be dynamically produced at runtime.  

So, for Errai, implicit dependent beans are a compile-time feature. Not a runtime feature.

But wait! It turns out there's a common need to dynamically lookup @Dependent beans in Errai applications. Widgets, for instance, are more often than not, of the @Dependent scope. And many widgets you want to instantiate many times, dynamically. Which is a perfect fit for the @Dependent scope. 

So to allow you to overcome the limitation we impose, you can annotate your bean with a @Dependent annotation. This explicit scoping is treated as signal that you want to interact with the bean via the bean manager. And that's why you've had to explicitly scope all your @Templated and @Page beans up until now.

But as it turns out, we've changed the rules. In the absence of an explicit scope, Errai will now consider the use of either of these two annotations to mean the same thing as an explicitly-scoped @Dependent bean.

The good news is that this improvement will be directly available in the next 2.2 release. And in final.

Hopefully this improvement makes your coding experience a little bit more pleasant. It has for us.

7 comments:

  1. Boosting maximum power is done by training between 85-100% of MMP. If you don't have a power meter your heart rate should be above 94% of maximum. If you don't use a heart rate monitor you should be experiencing similar effects as above, stressed, gasping, and sweating. testoultra If you don't use a heart rate monitor you should be experiencing similar effects as above, stressed, gasping, and sweating. https://goldencondor.org/testoultra/

    ReplyDelete
  2. I'm very happy being Herpes free now. It was a sad incident that was announced to me after the check up in the hospital and I was diagnosed of HSV 2. I thank God now for using Dr.odey Abang to cure my virus. I'm not ashamed to say this because no virus of such can be detected in me. I'm Charlotte from Columbia. I thought about it many Times when I heard about this Herbal cures for Herpes. I was really happy when I came across blogs of comments of Doctors who run cures sicknesses and was comfortable to try Dr. Abang from patients testimony I came across here on my online page. I knew now they are real Africa herbalists who run cures for Herpes. There's every opportunity to be cure with natural herbs, because all medical prescriptions are derived from herbs and roots. Its really hard time living with Herpes on drugs which can't get you cure. I tried this and I can boost of myself now as a woman. I need to be loved not to lost, get your instant cure to all sicknesses from Dr, Odey Abang.
    He cures HSV,HPV,Cancer,low spam count and much more from the evidence I saw 💯 % sure no site effects with active immune booster

    Email him for you cure
    Odeyabangherbalhome@gmail.com
    WhatsApp/calls
    +2349015049094

    ReplyDelete
  3. I’m here to testify about what Dr Oseremendid for me. I have been suffering from (GENITAL HERPES VIRUS) disease for the past 4 years and had constant pain and inching, especially in my private part. During the first year, I had faith in God that i would be cured someday.This disease started circulating all over my body and I have been taking treatment from my doctor, few weeks ago I came across a testimony of Rose Smith on the internet testifying about a Man called Dr Oseremen on how he cured her from 7 years HSV 2. And she also gave the email address of this man, advise anybody to contact him for help on any kind of diseases that he would be of help, so I emailed him telling him about my (HSV 2) he told me not to worry that I was going to be cured!! Well, I never doubted him I have faith he can cure me too,, Dr Oseremen prepared and sent me Healing Oil, Soap, roots and herbs which I took. In the first one week, I started experiencing changes all over me, after four weeks of using his Roots/ Herbs, Oil and Soap, I was totally cured. no more inching , pain on me anymore as Dr Oseremen assured me. After some time I went to my doctor to do another test behold the result came out negative. So friends my advise is if you have such disease or know anyone who suffers from it or any other disease like HPV, HBV, HIV, ALS, HBP, CANCER etc. you can contact Dr oseremenfor help via dr.oseremenvadi@gamil.com or whatsapp +2349056394313

    ReplyDelete
  4. https://saudi-germany.com/ شركة السعودي الالماني للخدمات المنزلية
    https://saudi-germany.com/%d8%b4%d8%b1%d9%83%d8%a7%d8%aa-%d8%aa%d9%86%d8%b8%d9%8a%d9%81-%d8%ae%d8%b2%d8%a7%d9%86%d8%a7%d8%aa-%d8%a8%d8%ac%d8%af%d8%a9/ شركات تنظيف خزانات بجدة
    https://saudi-germany.com/%d8%aa%d9%86%d8%b8%d9%8a%d9%81-%d8%ae%d8%b2%d8%a7%d9%86%d8%a7%d8%aa-%d8%a8%d8%ac%d8%af%d8%a9/ تنظيف خزانات بجدة
    https://saudi-germany.com/%d8%a7%d9%81%d8%b6%d9%84-%d8%b4%d8%b1%d9%83%d8%a9-%d8%aa%d9%86%d8%b8%d9%8a%d9%81-%d8%ae%d8%b2%d8%a7%d9%86%d8%a7%d8%aa-%d8%a8%d8%ac%d8%af%d8%a9/ افضل شركة تنظيف خزانات بجدة

    ReplyDelete
  5. https://saudi-germany.com/cleaning-tanks-company-taif/
    https://saudi-germany.com/cleaning-tanks-company-mecca/
    https://saudi-germany.com/jumperads-transfer-furniture/

    ReplyDelete