Sunday, November 4, 2012

The reRender property of a4j:commandButton or a4j:commandLink can be used to reRender other JSF - richFaces components.

Steps:
1) Mention the component IDs to be reRendered in the "reRnder" attribute of the a4j:commandButton, separated by comma. This will make those components get reRendered on button click. 

2) If its a4j:mediaOutput step 1 will not make the image to be refreshed. Reason being, the mediaOutput tag will cache the image until there is a change in the "value" attribute.

So even if you don't want to "value" attribute, use it and bind it with a method that returns random value (say random Number or time)

Sample code is given below:

<h:form >
       <a4j:commandButton value="RefreshImage"
              action="#{testBean.clickButtonAction}"
              reRnder="outputImage,output"/>
<rich:Panel>
<a4j:outputPanel id="outputImage">

<a4j:mediaOutput createContent="#{graphBean.paint}" value="#{graphBean.time}" mimeType="image/jpeg" id="output" element="img" cacheable="false" session="false"/>
</a4j:outputPanel>
</rich:Panel>
</h:form>