I am wondering if there is an API in Primefaces to push some javascript to the client during a server side call, which is then queued and evaluated on page load??
I am looking for simular functionality as IceFaces JavascriptContext.addJavascriptCall( 'blah' );
I have tried using "oncomplete", but unfortunately (for me) the oncomplete javascript is parsed "onsubmit" prior to completeing the request, so it makes it hard to render the javascript dynamically. For example, if the server state is responsible for determining the javascript state....
I have also tried to "repaint" a form (which contains new javascript) but the DOM does not seem to recognise the new script and continues evaluating the old javascript...
My application requirements are to do something after a form submission in javascript, based on the server response... I.E if (true) do this... else do that... where TRUE is dynamic from server..
To achieve this, I have also tried to dynamically write out a javascript function "onSearchReturn()" inside the form ''flightOptionForm" which is repainted after a partial submit....
Even though the function is rewritten, the page DOM does not seem to recognise the new javascript in memory??
Code: Select all
<p:commandLink id="searchAction" onclick="if (!validate()) return false;" value="Search Flights" action="#{aggregationSearchOptions.returnOptions}" update="flightOptionForm,totalForm,flightOptionsForm_Return,flightOptionsForm_Departing,bestOptions" styleClass="search-flights button" oncomplete="onSearchReturn()" />
Code: Select all
<script type="text/javascript">
/* <![CDATA[ */
function onSearchReturn(){
if(#{aggregationSearchOptions.errorMessages}){#{requestScope['validationJavascript']}}else{toggleModifySearch(null);}
}
/* ]]> */
</script>
Colm