2

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.

geeehhdaa
  • 822
  • 5
  • 17
  • 30

1 Answers1

4

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>.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555