effectsraka.blogg.se

Alternative class for icefaces javascriptcontext
Alternative class for icefaces javascriptcontext







ALTERNATIVE CLASS FOR ICEFACES JAVASCRIPTCONTEXT UPDATE

With the introduction of server push where the server can update the client asynchronously outside a request context, a static FacesContext object is not available. In a classic client/server request/response environment with no long polling (outstanding XMLHttpRequests that are used for server push), JSF's FacesContext is always available because everything happens in the context of a request.

alternative class for icefaces javascriptcontext

For posterity, I fixed this by getting FacesContext instance from PersistentFacesState.getFacesContext() in the constructor of the application-scoped bean that needs to fire the client side Javascript and storing its reference as an instance variable. Who is calling the addJavascriptCall? Are you using spring? For sping, we have a little work around. The current thread must know about the actual FacesContext. There must be a way to push a Javascript call to the client?

alternative class for icefaces javascriptcontext

I have also tried putting an element on the page with an onChange() function and changing the element value from the server (value="#") but the onChange() method never fires. I have tried the outputText workaround above and all it does is display the Javascript in the browser - I must be doing something wrong. But in my method that gets invoked by a background process (a thread that is polling a datasource) FacesContext.getCurrentInstance() returns null, so passing it to FacesContext in addJavascriptCall(FacesContext, String) yields an NPE.

alternative class for icefaces javascriptcontext

I'm not sure if that last statement makes any sense, since there is always a request going on, even if it is an XMLHttpRequest. I think this is because FacesContext is null since there is no request context. JavascriptContext.addJavascriptCall() does not seem to work when the server asynchronously updates the browser using server push.







Alternative class for icefaces javascriptcontext