JSF: Partially adding text to component from AJAX call [duplicate]
I want a inputTextarea to display lines appended to some text file. I imagine it like this: The user clicks a commandButton that does a AJAX call.
My problem is: The text will only be rendered when the action returns. However, my action should look like this:
while(true) {
String newData = getSomeMoreDataFromServer();
// append the new data to a textarea and the user should see it immediately
if(blabla) { break; }
}
Is this even possible? The part that's commented out is the part that bothers me.
Can the user even set the break condition in the form somehow?
I'm using JSF 2 (MyFaces) + Tomahawk.
That's not possible from inside the backing bean action method. Also having a while(true)
is very CPU-inefficient, you'd rather like to avoid that in a multi-user environment. What you're looking for is ajax poll/push. This is not provided in the standard JSF implementation and also not in Tomahawk. PrimeFaces for example, supports ajax poll/push components <p:poll>
and <p:push>
.
精彩评论