[jsr-314-open-mirror] [jsr-314-open] Repetitive calls to FacesContext.getCurrentInstance() from listeners of system events
Leonardo Uribe
lu4242 at gmail.com
Tue May 25 02:17:12 EDT 2010
Hi
Issue created:
https://javaserverfaces-spec-public.dev.java.net/issues/show_bug.cgi?id=807
best regards,
Leonardo
2010/5/25 Leonardo Uribe <lu4242 at gmail.com>
> Hi
>
> Reviewing some stuff, it was notice that the FacesContext instance is not
> passed when event processing occur, so every time a system event should be
> processed, a call to FacesContext.getCurrentInstance() should be done in
> almost all cases.
>
> Below there are one example based on myfaces code (removed non relevant
> code):
>
> public class HtmlStylesheetRenderer extends Renderer implements
> ComponentSystemEventListener
> {
>
> public void processEvent(ComponentSystemEvent event)
> {
> UIComponent component = event.getComponent();
> FacesContext facesContext = FacesContext.getCurrentInstance();
> facesContext.getViewRoot().addComponentResource(facesContext,
> component, "head");
> }
> ......
> }
>
> It could be good to pass the current facesContext (note the code in
> Application.publishEvent receive it as param), to prevent those unnecessary
> calls and enhance code performance. In theory it is possible to cache
> facesContext object on listeners suscribed using
> UIViewRoot.subscribeToViewEvent() because those listeners are not saved (but
> maybe not because if the same view is used on portlet....), but that's not
> possible on ComponentSystemEventListener instances.
>
> I'll open an issue for this one.
>
> regards,
>
> Leonardo Uribe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jsr-314-open-mirror/attachments/20100525/d3f562e2/attachment-0002.html
More information about the jsr-314-open-mirror
mailing list