I have a webpage using a javascript. The code sample:
<script type="text/javascript">
var shown = 0;
function showOrHidePanel()
{
var isComplete = '<h:outputText value="#{general.sessionCompleted}" />';
if (isComplete == true){
if (shown==0) {
Richfaces.showModalPanel('pnl',{width:550, top:200});
}
shown = 1;
} else {
if (shown == 1) {
Richfaces.hideModalPanel('pnl');
}
shown = 0;
}
return;
}
</script>
<a4j:region>
<h:form>
<a4j:poll id="poll" interval="10000" reRender="pnl" action="#{general.checkOnDrcSession}"
oncomplete="showOrHidePanel()" />
</h:form>
</a4j:region>
The effect i’m trying to achieve is to make the modalpanel be shown by the polling component only once whenever sessionCompleted becomes true (So it wont show the flickering page effect on every re-show of the modalpanel.
But i’m a javascript newb and i’m afraid that, in addition to this not working correctly, I get a ‘true’ text at the top of the page.
When i take down the var isComplete = '<h:output... declaration, the ‘true’ text disappears.
Thanks for the help…
Get rid of those singlequotes.
You want to end up with
and not with
in the generated output.
Alternatively, you can also just do