0

I am trying to use push / update function in java for a web application...

My use : Java (JRE 8) / Primefaces 6.2 / GlassFish 4.1.1 / SqlServer

Goal : Thread in java doing Select into the Sql database. whenever a value has changed, refresh it into my web page

What i have done :

Java side :

A thread (@ApplicationScoped + @ManagedBean(name="Application")) it is doing a select of values each second. When a value has changed -> detect it

When i detect that some values has changed, i am doing this :

PrimeFaces.current().ajax().update("disponibilite:Vehicule");

Of course, my component in my xhtml page is linked to the related values through this :

value="#{Application.m_listeDisponibiliteVehicule}"

BUT

When i am running my app, on the update line, there is a null pointer like if the component with the given id wasn't found by my java side.

java.lang.NullPointerException at org.primefaces.PrimeFaces$Ajax.update(PrimeFaces.java:278) at Database.ThreadDB.run(ThreadDB.java:86)

The problem is :

How can i simply refresh components when my server-side decide to do it.

Thank you for helping

XHTML : https://i.stack.imgur.com/Z5WZT.jpg

Java Side : https://i.stack.imgur.com/CjCnG.jpg

Error : https://i.stack.imgur.com/tAf8l.jpg

Tomvf23
  • 1
  • 1
  • Code should be in text, not images. And please learn about real PUSH... Ajax is not the way to go here – Kukeltje Jun 06 '18 at 10:55
  • Possible duplicate of [How can server push asynchronous changes to a HTML page created by JSF?](https://stackoverflow.com/questions/3787514/how-can-server-push-asynchronous-changes-to-a-html-page-created-by-jsf) – Kukeltje Jun 06 '18 at 10:56
  • @Kukeltje thank yu for replying, could you please explains a bit on how using real push (on JSF 2.2)? (i am new to web development) – Tomvf23 Jun 06 '18 at 11:39
  • That is all in the link I posted – Kukeltje Jun 06 '18 at 11:41
  • I already go for the Primeface / Atmosphere usage, but i struggling on setting up the configuration... I have the atmosphere runtime 2.4.24.jar i have try to put this into the "web.xml" : Push Servlet org.primefaces.push.PushServlet 1 true Push Servlet /primepush/* – Tomvf23 Jun 06 '18 at 11:46
  • but, aout the "pom.xml", i ca't even find that file. i read some tutorials, explanations about the usage of atmosphere, it looks like the "pom.xml" defines the dependencies. any ideas ? – Tomvf23 Jun 06 '18 at 11:51
  • If you don't use maven, you don't have a pom and you need to do dependency management yourself or via the tool that you **do** use. Can't help you with that. The required dependencies can be found in either the PF docs or the atmosphere docs. – Kukeltje Jun 06 '18 at 13:09
  • Hello again, i am using netbeans IDE 8.2 i can't find any "dependencies" folder or something that looks like this... i can't beleive it is so hard to implements push features... – Tomvf23 Jun 06 '18 at 14:26

0 Answers0