Question

for example, I've tried

<a4j:region id="scriptSuggested" >
<f:verbatim>
<script>
  reallyUpdateIt = function () {
       // javascript code that changes after aj4 ajax call is triggered
      }
    </script>
   </f:verbatim>
    <a4j:jsFunction reRender="scriptSuggested" ignoreDupResponses="true" ajaxSingle="true" name="updateSuggestionValues" action="#{bean.action}" oncomplete="reallyUpdateIt();">
        <a4j:actionparam name="userInput" assignTo="#{bean.input}" />
    </a4j:jsFunction>
</a4j:region>

I would expect that calling the javascript function

updateSuggestionValues('val');

is going to do the action

#{bean.action}

and after that it would rerender the region scriptSuggested and finally would call reallyUpdateIt() ,

all works except the part of updating the code of reallyUpdateIt(), I checked the ajax response using firebug, and it comes with the expected new javascript code, but when I call reallyUpdateIt() , the old code is triggered.

I am using JSF 1.2, richfaces 3.3.3,

Was it helpful?

Solution

it turns out using <a4j:region id="scriptSuggested" > doesn't generate an html section that A4J can rerender, I had to use <a4j:outputPanel> , so now it updates the function, my code now looks like :

<a4j:region >
<a4j:outputPanel id="scriptSuggested">  
<f:verbatim>
<script>
  reallyUpdateIt = function () {
       // javascript code that changes after aj4 ajax call is triggered
      }
    </script>
   </f:verbatim>
    <a4j:jsFunction reRender="scriptSuggested" ignoreDupResponses="true" ajaxSingle="true" name="updateSuggestionValues" action="#{bean.action}" oncomplete="reallyUpdateIt();">
        <a4j:actionparam name="userInput" assignTo="#{bean.input}" />
    </a4j:jsFunction>
</a4j:outputPanel>
</a4j:region>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top