[weld-dev] @Inject FacesContext

Dan Allen dan.j.allen at gmail.com
Tue Nov 10 17:21:31 EST 2009


> The reason for injection is to be able to stub and unit test easily. Right
> now the getCurrentInstance() is static and you'd need to use ugly
> constructions to replace it with a stub (I am not saying it's impossible but
> I am talking here from the feedback I've gathered and personal experience
> when unit testing pure JSF).
>

And the other, more subtle annoyance is the you have to eventually make that
decision in a method when to create a local variable for FacesContext
because your code is getting too verbose.

FacesContext ctx = FacesContext.getCurrentInstance();

I hate writing that line. Every time I do, I think to myself "I hate this
stupid line of code."

-Dan

-- 
Dan Allen
Senior Software Engineer, Red Hat | Author of Seam in Action
Registered Linux User #231597

http://mojavelinux.com
http://mojavelinux.com/seaminaction
http://www.google.com/profiles/dan.j.allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20091110/e0730859/attachment.html 


More information about the weld-dev mailing list