I have a custom javascript Ajax call in my jsf page. I capture and process the query string of the XMLHttpRequest in a filter. The filter adds a record to a table in the model.
Now I want the jsf page, without full page refresh, to reflect the updated model in one of the components (a Primefaces data table).
I guess what I need is a custom xmlHttpResponse…
Can anyone tell me how to do this? I’m scared it might be complicated, but I have no choice but to use the custom javascript…
The PrimeFaces
<p:remoteCommand>is designed for this purpose.Here’s a basic kickoff example for your particular case:
It generates a JS function
updateTable()which will invoke the#{bean.updateTable}method and update the component with (relative) client IDtable. You just have to call the functionupdateTable()in JavaScript context.You can even pass request parameters if necessary, it has to be sent as JS object:
No need to fiddle with homebrewed ajax requests and keeping the JSF state in sync.