Reputation: 3884
I'm executing an external application (by using Runtime.getRuntime().exec
... example here) and I'm listening on the Stream the app writes stdout to.
That part is working as intended and I get results (in grails controller), line by line, as they are available and -- when the stream has no more content -- I render the result on the page.
Other aspect is initiation of that application from the gsp page, asynchronously. That is also already covered and the remoteFunction call is made (to the above mentioned controller method), the results are gathered and returned and they are correctly displayed in designated area on the page.
But, what is bugging me and what I actually want to achieve is:
to display the lines read from the stream as they are read, not after the whole stream finishes (as it is done now).
That means (something like, for example) calling render for each line in the Stream-reading loop:
while ((line = bri.readLine()) != null) {
System.out.println(line);
//render line here?
}
Can this be achieved?
Please explain :)
Upvotes: 3
Views: 754
Reputation: 4697
I think there is no standard grails way to achieve your desired behavoir.
The g:remoteFunction ist still an tag that wraps the AJAX request for you. The request is bounded to the request response pattern - you can't get multiple responses for one request. Your action code won't be modified automatically.
You have to implement it on your own.
I would try the following:
Upvotes: 2