jsf - Triggering Ajax event when an object changes its state -
I have a small university project in which I have to show how some algorithms work. Decided to use JSF for a simple webpad and to save all the algorithm-generated data in the database.
I thought, 'Hey, it would be good if I can show the user how the algorithm works by step, nothing is fancy, only plain formatted text, when the algorithm talks about it . An output text field should work with Ajax! ', But I did not get enough of my head about a certain problem. Ajax triggers when there is a certain event, like 'click' or 'keys', but is this a way to trigger when an object changes in my Manbadden class?
I do not know if I have explained well enough, here's an example of what I want to do:
- An ArrayList is empty in the managed bean, output Text does not print anything
- After a certain time, a new object is saved in ArrayList, Ajax triggers and output text prints its onstring () string
- Then some After a while, the same object that was printed before the changes Obtained, Ajax trigger and output text accordingly changes
I'm sorry if the problem is not clear enough, then try to describe its potential.
What you describe is not a classic, client-triggered AJAX, but (SSE) is referred to as. They are typically implemented for long periods of voting (using periodic client requests, which are only received in response to a server-side event).
Your favorite JSF Toolkit might support it under the name "Push". Here's one.
However, in case of your simplicity, I recommend using Voting instead. The main difference is that your server side logic is switched to keep a list of "to display" string / id / object when your browser chooses the customer server (called the listener), a beacon Assign the first item to the string
field in the bean and re-enter your client the region where it is shown string
.
Note that you can do this in plain JSF-2, there is no need to have a prefix.
Comments
Post a Comment