-
1. Re: Using a4j:mediaOutput to display a JPEG from a BLOB
ilya_shaikovsky Oct 7, 2010 4:10 AM (in response to notify)using mediaOutput you just passing the image data to Stream. So seems something wrong with your "paint" method as mediaOutput really doesn't care from which source you will get the data you passing to stream.
-
2. Re: Using a4j:mediaOutput to display a JPEG from a BLOB
notify Oct 7, 2010 4:28 AM (in response to ilya_shaikovsky)When I use rich:fileUpload and then preview the uploaded file, from the RF example page everything works fine. Will look at paint method.
<rich:fileUpload fileUploadListener="#{fileUploadBean.listener}"
maxFilesQuantity="#{fileUploadBean.getUploadsAvailable()}"
id="upload"
immediateUpload="#{fileUploadBean.isAutoUpload()}"
acceptedTypes="jpg" allowFlash="#{fileUploadBean.isUseFlash()}">
<a4j:support event="onuploadcomplete" reRender="info" />
</rich:fileUpload>
Bean's paint;
public
void paint(OutputStream stream, Object object) throws IOException {
stream.write(getFiles().get((Integer) object).getData());
}
-
3. Re: Using a4j:mediaOutput to display a JPEG from a BLOB
ilya_shaikovsky Oct 7, 2010 4:34 AM (in response to notify)seems that getFiles().get((Integer) object).getData() not returns data properly. check object scope.
-
4. Re: Using a4j:mediaOutput to display a JPEG from a BLOB
notify Oct 7, 2010 9:55 AM (in response to ilya_shaikovsky)As the images are in the Entity Bean returned as a collection from my EJB JPA call to the table should I change the paint method to refect this then?
The stream.write should write out my Postcard entity i.e
postcard.getImage();
-
5. Re: Using a4j:mediaOutput to display a JPEG from a BLOB
ilya_shaikovsky Oct 7, 2010 10:26 AM (in response to notify)I just mean that you should check in debug if the objects which should be passed to Stream actually correct when it called.
-
6. Re: Using a4j:mediaOutput to display a JPEG from a BLOB
notify Oct 8, 2010 4:33 AM (in response to ilya_shaikovsky)Ilya,
It looks like the a4j:mediaOutput is unable to pass the reference to the BLOB (byte []) from my Entity Bean. The call to a4j:mediaOutput is inside a rich:dataTable.
If I just display the BLOB (no call to a4j:mediaOutput) i get the refence to it displayed.
I pass something else and it calls the method (fileUploadBean.paint), all be it null.
Is this a known issue?
Thanks.
<
rich:dataTable id="dataTableYourPhotographs" value="#{postcardsList}" var="postcards" columns="4" rendered="#{postcardsList.size() > 0}" >
<rich:column style="text-align: center;">
<f:facet name="header">Date/Time Added</f:facet>
<h:outputText value="#{postcards.dateOfImage}" >
<f:convertDateTime pattern="dd/MM/yyyy HH:mm" timeZone="Europe/London" />
</h:outputText>
</rich:column>
<rich:column>
<f:facet name="header">Location</f:facet>
<h:outputText value="#{postcards.googleMapsReverseGeocodeAddress}" />
</rich:column>
<rich:column>
<f:facet name="header">Postcard</f:facet>
<a4j:mediaOutput element="img" mimeType="image/jpeg"
createContent="#{fileUploadBean.paint}" value="#{postcards.image}"
style="width:100px; height:100px;" cacheable="false">
</a4j:mediaOutput>
</rich:column>
<rich:column style="text-align: center;">
<div class="actionButtons">
<a4j:commandButton action="#{geofenceBean.deletePostcard}" value="Delete Postcard" reRender="dataTableYourPhotographs" />
</div>
</rich:column>
</rich:dataTable>
-
7. Re: Using a4j:mediaOutput to display a JPEG from a BLOB
ilya_shaikovsky Oct 8, 2010 7:08 AM (in response to notify)one more time.. if you getting the object from Entity directly successfully and the controller which tries to get it and pass to Stream can't get it - it's a problem of objects interaction design. And responsibility of the component - just call the paint method. If it called - all works fine at component level.
-
8. Re: Using a4j:mediaOutput to display a JPEG from a BLOB
notify Oct 8, 2010 7:30 AM (in response to ilya_shaikovsky)Okay.
I can't pass the BLOB = byte [] to the POJO which does the paint method.
The BLOB can be displayed as its 'ID', say "[B@1957bfa"
But when I try and pass this to paint it the paint method doesn't get called. I can call the paint method when I pass a String, so it must be problem with the byte array.
Like you say it must be "a problem of objects interaction design". Will investigate.
Thanks for all your help.
-
9. Re: Using a4j:mediaOutput to display a JPEG from a BLOB
ilya_shaikovsky Oct 8, 2010 8:49 AM (in response to notify)b.t.w. one side effect which is present with mediaOutput could cause problem of paint method not get called. If the image for that BLOB was already shown before - browser could believe that it should be get from cache. And yes in that case method will not be called. take a look there http://livedemo.exadel.com/richfaces-demo/richfaces/fileUpload.jsf to check how it solved for FU sample. (look to f:param which adds timestamp to media component every time before reRendering so the URL of image resources differs for requests.) cacheable attribute - controls server side caching only. But that influence only reREnder'ing and if you encountering on the first rendering - should not be the cause.
Message was edited by: Ilya Shaikovsky
-
10. Re: Using a4j:mediaOutput to display a JPEG from a BLOB
notify Oct 14, 2010 6:04 PM (in response to ilya_shaikovsky)Unable to get a4j:mediaOutput to pass a byte [] (BLOB from an Entity Bean) to a method in a Seam Bean.
I have used;
<s:graphicImage value="#{postcards.image}">
<s:transformImageSize width="300" maintainRatio="true"/>
</s:graphicImage>
Worked perfectly, would have saved days of frustration!
-
11. Re: Using a4j:mediaOutput to display a JPEG from a BLOB
nbelaevski Oct 14, 2010 8:54 PM (in response to notify) -
12. Re: Using a4j:mediaOutput to display a JPEG from a BLOB
micnight Feb 8, 2011 8:27 AM (in response to nbelaevski)Hi Nick,
this article helped me a lot to solve my problem (uploading and displaying pictures with Portlet Bridge in GateIn). Thank you.
Regards,
Michael