0

The application itself is about generating word-search puzzles. On the view (index.xhtml), there is a form collecting parameters such as rows, cols, etc. Clicking the "generate a puzzle" button invokes the "generate" method in the backing bean. The algorithm can run for a while, so I want to display message like "generating your puzzle, please wait" on the view. After the puzzle is generated, the message should disappear and the puzzle should show. Basically the application works fine but the waiting message is not showing. I did similar things very easily with Angular but so far failed to get it work with JSF (some of my projects have to use JSF that's why I'm investigating JSF).

Core of my question is, how to ask the view to observe some boolean flags in the backing bean, and update parts of the view immediately when the boolean flags change. Those boolean flags are all set within the "generate" method, and they change value from true to false or vice versa within the same method, the view should change accordingly.

Here is the source code of my application:

Any enlightenment will be highly appreciated!

Nicole Naumann
  • 874
  • 2
  • 8
  • 19
  • 1
    You can use web sockets for this: https://stackoverflow.com/questions/3787514/how-can-server-push-asynchronous-changes-to-a-html-page-created-by-jsf/49852105#49852105 – Selaron Nov 19 '18 at 09:05
  • 1
    Don't even think websockets are needed here. Plain ajax would do. – Kukeltje Nov 19 '18 at 10:55
  • @Kukeltje, I tried f:ajax but failed to get the message appearing...must be doing something wrong...... – Nicole Naumann Nov 19 '18 at 11:09
  • @Selaron, thank you very much for the hint, I'll try it! – Nicole Naumann Nov 19 '18 at 11:10
  • 1
    @NicoleNaumann as you already have primefaces in use, `p:poll` might be an alternative AJAX way. A disadvantage is that it requests the server again and again, as its' name suggests. – Selaron Nov 19 '18 at 11:46
  • 1
    If you tried generic ajax and did not get a messag appearing, pleaseask a specific question about that with a [mcve]... effectively your question is in no way jsf2.3 related but plain jsf 2 then – Kukeltje Nov 19 '18 at 13:50

0 Answers0