Using JBoss 7.1.1.Final and running a very basic restful web service. I have a linux dream plug box running a node js http client that connects to the web service at port 8080. It sends a request and gets back JSON data from the webservice just fine. I have a very simple jsf page with just a button and the action goes to lets say Xbean. Xbean then makes a primepush event on this action to the node js app. Node JS app then gets this event and performs some background process to get some data, then with an http get request, sends back some data to some predefined rest URL. So my browser is currently on the jsf page where I hit the button and I want that page to show the information returned from the node js app. That information resides in the push resource bean, but not on the bean that is used to display on the jsf. How do I have the jsf get the info from the resteasy resource and display it in the jsf page? do i use applicationscoped bean? thanks
Asked
Active
Viewed 467 times
1
-
If I understood, you consume a web service (JAX-RS, JAX-WS, whatever) from your managed bean, get the result (maybe in JSON form) and want to display the results in your view (your JSF page), right? – Luiggi Mendoza Apr 03 '13 at 03:49
-
yes correct! I want to display in same JSF page that is up on the browser that i used to trigger the push event. – zoroloco Apr 03 '13 at 03:53
-
Assuming your JSON data has the structure of the beans you use in your project, you can just deserialize the data using a JSON library like [GSON](https://code.google.com/p/google-gson/) or [Jackson](http://jackson.codehaus.org/), populate a `List
` with your data and use the list to display the results on your JSF page. – Luiggi Mendoza Apr 03 '13 at 03:55 -
i have a managedbean that has a method that successfully consumes a JSON object from the node JS app. With a breakpoint in that method, I can see that I have all the data. How do I show this data on the JSF page my browser is on? I cannot return html from that same method because that html response would go back to the node js app. I want the output to go to the browser. – zoroloco Apr 03 '13 at 04:07
-
Are you calling this service with a button click or by pushing from server to client? – Luiggi Mendoza Apr 03 '13 at 04:13
-
button click on the jsf triggers an action method on some managed bean, which then creates a push context and sends out push to some channel that node js app is already listening to. when node js app gets this push, it then sends an http request to the web service. – zoroloco Apr 03 '13 at 04:17
-
localhost:8080/foo/sendpush.jsf is the page where i click the button that sends out the push. The bean associated with this is called sendbean. localhost:8080/rest/responses/push is the rest url that the node js http client sends the json post data to. The resource associated to that rest url that consumes the data is called pushbean. I want the data that i now have in pushbean to show on the url localhost:8080/foo/sendpush.jsf – zoroloco Apr 03 '13 at 04:20
-
1I guess you're confusing a PrimeFaces Push action with a RESTful web service consumption. Are you really using PrimeFaces Push for this work or consuming your service directly in your managed bean? Also, it will be **better** if you post a code fragment when somebody could simulate your problem in order to get a better idea and provide an useful solution. – Luiggi Mendoza Apr 03 '13 at 04:22