fs.
fs.

Reputation: 162

Icefaces: server push issue

I have been working with icefaces since its version 1.8 and now I am getting into the latest version (3.0). I think my problem is not version related, but the solution could be. I am programming an application which uses ICEpush. The model is like this: Several devices are connected to the server via java.net.socket and running in an independent thread and every message could trigger an ajax push event. When I use PushRenderer.Render("group") I get this: java.lang.RuntimeException: FacesContext is not present for thread Thread[172.17.1.49,5,main]. When I use SessionRenderer.Render("group") it works as expected when I go the main page of the devices and I can see how the information changes on real time for everyone. The problem I find is that when I try to navigate to another view in my application I see that it is done in a very slow way and the buttons after I click on them do not work. When I refresh the page they start working again until I navigate to the page of the devices where I get the problem again. I have tried with the PortableRenderer but if I use PushRenderer.getPortableRenderer() I get a nullPointerException; and, if try to use PushRenderer.getPortableRenderer(FacesContext.getCurrentInstance()) I find that this method has changed its parameter to ServletContext that I do not know where I can find it.

I hope you can help me with this.

thanks in advance.

Upvotes: 1

Views: 1078

Answers (2)

gogognome
gogognome

Reputation: 759

Call PushRenderer.getPortableRenderer() from within the faces context. For example in the constructor of a managed bean. The portable renderer can than be passed to another thread and called later outside the faces context.

Upvotes: 1

fbertos
fbertos

Reputation: 11

You can get the ServletContext from your FacesContext, like this:

ServletContext servletContext = (ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext();

Upvotes: 1

Related Questions