I have this:
<a4j:region>
<a4j:outputPanel id="mypanel">
<a4j:mediaOutput rendered="{check}" standby="please wait.." session="true" element="object" mimeType="audio/mpeg" createContent="#{myBean.playAudio}" value="audioID2" cacheable="false"/>
</a4j:outputPanel>
</a4j:region>
<a4j:commandLink value="play" action="#{myBean.setCheckToTrue}" reRender="mypanel" limitToList="true" ajaxSingle="true"/>
my method myBean.playAudio:
public synchronized void playAudio(OutputStream stream, Object value)
{
...
byte[] a = new byte[1];
// fill byte-array
..
// write stream
stream.write(a);
stream.flush();
stream.close();
}
All works, but the method playAudio is
always called twice. Imagine, having a 10MB-byte[] and do the stream.write() twice (as, for what ever reason, the method is calling twice).
How can I force that the playAudio-method of rich:mediaOutput is only called once and not twice ?
Another thing is, the standby="please wait.."-property does not work for me. Even the rich:mediaOutput is rendered, I have to wait until the stream is written by playAudio-Method. So in the meanwhile, I expect, that the standby-label "please wait.." is visible, but I do not see this label.