Question

How can I use a parameter inside a jsFunction? I'm just trying to do something like this, but I't doesn't work, even using a backing bean variable instead #{id}

<a4j:jsFunction name="test" reRender="#{id}" oncomplete="alert('#{id}');">
  <a4j:actionparam name="id" assignTo="#{id}" />
</a4j:jsFunction>


<a4j:commandButton immediate="true" onclick="test('outputPanel1');"/>
<a4j:commandButton immediate="true" onclick="test('outputPanel2');"/>
<a4j:commandButton immediate="true" onclick="test('outputPanel3');"/>

I know I could use a reRender in each commandButton, but this is just an example to show the behaviour I want.

I'm using richfaces 3.3.3.

Thanks

Was it helpful?

Solution

Here is an example of what you are trying to achieve on livedemo: http://livedemo.exadel.com/richfaces-demo/richfaces/jsFunction.jsf?c=jsFunction&tab=usage

Try to follow that. Comparing with your example, try changing to (form needed around the jsFunction, no need to submit request on button click):

<a4j:form>    
  <a4j:jsFunction name="test" reRender="#{myBean.id}" oncomplete="alert('#{myBean.id}');">
    <a4j:actionparam name="id" assignTo="#{myBean.id}" />
  </a4j:jsFunction>

  <a4j:commandButton onclick="test('outputPanel1'); return false;"/>
  <a4j:commandButton onclick="test('outputPanel2'); return false;"/>
  <a4j:commandButton onclick="test('outputPanel3'); return false;"/>
</a4j:form>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top