[weld-dev] @Inject FacesContext

Siarhei Dudzin siarhei.dudzin at gmail.com
Tue Nov 10 17:12:14 EST 2009


I don't post much here but I felt obliged to comment on this thread (and my
other message awaits for moderation).

I have to agree with Dan. This probably will be one of the most used
injections.

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).

If faces context will be injectable it will make many people happy :)

Btw, FacesContext.setCurrentInstance() is protected (so you can't just call
it) which means you'd need to make some 'suboptimal' constructions to make
it work in unit tests.

Best regards,
Siarhei Dudzin


On Tue, Nov 10, 2009 at 10:51 PM, Gavin King <gavin.king at gmail.com> wrote:

> Call FacesContext.setCurrentInstance() :-)
>
> On Tue, Nov 10, 2009 at 4:29 PM, Steven Boscarine
> <steven.boscarine at childrens.harvard.edu> wrote:
> >
> > Gavin King wrote:
> >>
> >> I didn't put it in, since I figured it was hard to justify that this
> >> is better than FacesContext.getCurrentInstance().
> >>
> >
> > How would one unit test a class that has such a call?
> >
> >
> >
>
>
>
> --
> Gavin King
> gavin.king at gmail.com
> http://in.relation.to/Bloggers/Gavin
> http://hibernate.org
> http://seamframework.org
> _______________________________________________
> weld-dev mailing list
> weld-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/weld-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20091110/f96596ab/attachment.html 


More information about the weld-dev mailing list