-
1. Re: a4j:mediaOutput - Error with Images larger than 2Kb
peter.falken Apr 18, 2012 9:20 PM (in response to peter.falken)Since <a4j:mediaOutput> Stores its data in a URI - it's not recommended to pass the Value of the Data to be drawn in the XHTML.
It is better to just pass an ID and fetch the Raw Data to be output the Paint Method.
Still I'm left with doubt as to how does the RichFaces ShowCase works with an 8Kb PNG Image and it doesn't work with my Development Environment.
a4j:mediaOutput and large objects as value
https://community.jboss.org/wiki/A4jmediaOutputAndLargeObjectsAsValue
How to use a4j:mediaOutput correctly for displaying images?
http://stackoverflow.com/questions/7677207/how-to-use-a4jmediaoutput-correctly-for-displaying-images
The correct code should look like this:
<a4j:mediaOutput element="img" createContent="#{tBean.paint}" cacheable="false"
mimeType="#{ff.contentType}" style="width:100px; height:100px;"
value="#{ff.id}" />
===================================
public void paint(OutputStream stream, Object object) throws IOException {
if(object instanceof Long){
TFile ff = dm.getTFile((Long) object);
System.out.println("Writting: "+ ff.getFsName() + " Bytes: "+ ff.getSize());
stream.write(ff.getData(),0, ff.getSize().intValue());
}
stream.close();
}