voyent
PersistentFacesState.getFacesContext() returning null  XML
Forum Index -> General Help
Author Message
man910

Joined: 11/May/2007 00:00:00
Messages: 31
Offline


Following the online examples, I'm implementing the Renderable interface to push my content onto the client when a JMS message comes in. Everything works fine. However, now I need to call some JavaScript, which requires an instance of FacesContext. When I call this on the PersistentFacesState object, it always returns null. Am I setting up the state correctly?
philip.breau


Joined: 08/May/2006 00:00:00
Messages: 2989
Offline


Hi,

You can just use FacesContext.getCurrentInstance();

Philip

.
man910

Joined: 11/May/2007 00:00:00
Messages: 31
Offline


That was what I tried initially but it doesn't work. It also returns null. That's why I resorted to using the PersistentFacesState object. I think it's because it's in a different thread that is handling the JMS message.
man910

Joined: 11/May/2007 00:00:00
Messages: 31
Offline


It turns out I had a typo in my faces-config.xml and therefore, the RenderManager wasn't set. However, I'm still getting null pointers when I try to add some JavaScript even though the FacesContext is no longer null. I read on another post that JavaScript is not supported for server push? Is this true?
philip.breau


Joined: 08/May/2006 00:00:00
Messages: 2989
Offline


No, it's entirely possible to use custom javascript on your page with ajax push. How are you trying to do this?

Philip

.
man910

Joined: 11/May/2007 00:00:00
Messages: 31
Offline


I'm calling the JavascriptContext.addJavascript(FacesContext, String). However, it fails on the call to BridgeExternalContext.getRequestMap() when it tries to getContextServletTable(), which returns null. I also call this method on normal, client-pulls without any issues.
ted.goddard

Joined: 26/Oct/2004 00:00:00
Messages: 874
Offline


As you observed, FacesContext.getCurrentInstance() will not be valid on the JMS thread; there is no current instance, because an HTTP request is not in scope.

JavascriptContext.addJavascript(FacesContext, String) should work using the FacesContext obtained from PersistentFacesState, however it may be necessary to first call

Code:
 ((com.icesoft.faces.context.BridgeFacesContext) facesContext).setCurrentInstance()
 


If this works in your application, please confirm, and we will add a documented, public API for that purpose.
[Email]
man910

Joined: 11/May/2007 00:00:00
Messages: 31
Offline


No, that didn't work. It's getting a NullPointerException on line 150 of com.icesoft.faces.context.effects.JavascriptContext class (v1.5.3).

Code:
Map map = facesContext.getExternalContext().getRequestMap();
 
Forum Index -> General Help
Go to:   
Powered by JForum 2.1.7ice © JForum Team