Javascript within a4j:outputPanel

View: New views
2 Messages — Rating Filter:   Alert me  

Javascript within a4j:outputPanel

by victorik :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Here is the situation. For example I have code like this

<a4j:commandButton action=XXX reRender="scriptPanel" ....../>

<a4j:outputPanel id="scriptPanel">
  <a4j:commandButton id="buttonToDisableWithJS" action=YYY ....../>
  *** I want to insert JS here which will be executed after every reload of outputPanel with id="scriptPanel" and will disable/enable commandButton with id="buttonToDisableWithJS"***
</a4j:outputPanel>

How can I do this since inserting just
<script type="text/javascript">
  .......
</script>
doesn't work for me (it's not invoked when panel is rerendered).

PS: i cannot use "disabled" attribute of a4j:commandButton since when disabled="true" then onclick for button is generated as onclick="return false;" (it doesn't generate the same js code as when disabled="false" for onclick event) but button can be enabled and used later with other part of js on the page and onclick="return false;" it's not what expected from button in the case.

Re: Javascript within a4j:outputPanel

by victorik :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

so, the solution is to enclose <script> ... </script> into <f:verbatim> tag (for jsf version prior to 1.2) to force it including plain html/script into component tree while rendering the page.