Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First things first, <a href="https://stackoverflow.com/questions/2090033/why-jsf-calls-getters-multiple-times/2090062#2090062">stop doing your business logic in your getter</a>. You should simply be returning the property. Below is one approach you could use. Make sure you check the link.</p> <p>Modify your <code>getPvtLog()</code></p> <pre><code>public String getPvtLog() { return result; } </code></pre> <p>Then define a method that will be used for your <code>actionListener</code> in <code>&lt;p:commandButton&gt;</code>to update <code>result</code>. Example: </p> <pre><code>public void click() { try { File logFile = new File(instanceRoot + "\\config\\ProcessVerification.log"); InputStream fis = new FileInputStream(logFile); result = readStream(fis); } catch (IOException e) { log.severe(e.getMessage()); } return result; } </code></pre> <p>Change the method name as you see fit. This is just a quick example. </p> <p>Now remove <code>type="button"</code> and instead of <code>onclick</code> change it to <code>oncomplete</code>. <code>onclick</code> is executed before an ajax request, you want <code>&lt;p:dialog&gt;</code> to pop up after the ajax request. I believe this is your main issue by the way. Also add an <code>actionListener</code> in your <code>&lt;p:commandButton&gt;</code>. </p> <pre><code>&lt;p:commandButton id="showLog" actionListener="#{pvtRunner.click()}" value="Show Log" oncomplete="dlg.show()" update=":logDialogContnet"/&gt; </code></pre> <p><strong>Sample</strong></p> <pre><code>&lt;p:dialog id="logDialog" header="PVT Log" widgetVar="dlg" height="400" width="600" dynamic="true"&gt; &lt;h:outputText id="logDialogContnet" value="#{pvtRunner.pvtLog}" escape="false"/&gt; &lt;/p:dialog&gt; &lt;h:form&gt; &lt;p:panelGrid id="mainPanelGrid" columns="1" styleClass="panelGridBorder panelGridCenter"&gt; &lt;p:commandButton id="showLog" actionListener="#{pvtRunner.click()}" value="Show Log" oncomplete="dlg.show()" update=":logDialogContnet"/&gt; &lt;/p:panelGrid&gt; &lt;/h:form&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload