Appending new line in log file display in JSF

572 Views Asked by At

I want to display log file in jsf by continuously reading the log file and appending the new lines in jsf view . such that i need to monitor the log file for any new logs and update the JSF page with the new appended lines (Ex:console Display Mechanism in Jenkins).

Note:

  1. I am using JSF2 + Richfaces 4.3 .
  2. Reading the log file in Remote machine using ssh .

I would really appreciate any help on this topic .

2

There are 2 best solutions below

0
Deepak Nagaraj On

I have problem in displaying the file , if i refresh the input text area component to reflect the new changes then the whole component get refreshed thus leads to display only the last appended content in view rather than appending the new lines to the previous content (i want to display the log file like if you tail -f log file in command prompt ).

  1. i have tried with poll , but cant get it worked .
  2. Now i am trying with push (even it will also refresh the component based on backing bean event )
  3. I want the content to be appended rather than overwriting the content .
0
Makhiel On

Something like this should work:

<a4j:poll id="poll" enabled="true" ontimer="append()" render="panel" />

<textarea cols="40" rows="10" id="tarea" />
<a4j:outputPanel id="panel">
    <h:outputScript>    
        append = function() {
            $('#tarea').append('\n#{bean.newLine}');    
        }
    </h:outputScript>
</a4j:outputPanel>

You have to rerender the JavaScript so that the new lines are fetched.

However, if you refresh this manually the lines will get lost as well, if you don't want that to happen you will have to keep track of the previously displayed lines.