-
1. Re: Possible MediaOutput Size Limitation
alexsmirnov Oct 9, 2007 5:44 PM (in response to jdbastin)"value" attribute for a mediaOutput component encoded as part of the image URL, and designed for a store small rendering parameters ( in this case, remdering method can be implemented with "lightweight" design pattern ).
In your case, it can be name or ID of the uploaded image, to find it in session bin or database.
Also, i have a second remark -, "mimeType " attribute define a http response header, and can't contain more then one value like "image/jpeg, image/gif". -
2. Re: Possible MediaOutput Size Limitation
jdbastin Oct 9, 2007 6:06 PM (in response to jdbastin)Thanks Alex. I updated the MIME type so that it is a single value. Also, according to the documentation for the value attribute:
IMPORTANT: Since serialized data stored in URI, avoid using big objects.
This makes me believe that the 5K limit is the threshold for "big objects" but how can I get the byte array into the PaintBean without using the value attribute to pass it in? Normally, I would use Seam's injection mechanism but PaintBean is special because it is declared in faces-config.xml. Do you have an example of how I can access the correct context for PaintBean to get data from my Seam based backing bean? Thanks again. -
3. Solution: Possible MediaOutput Size Limitation
jdbastin Oct 11, 2007 9:12 PM (in response to jdbastin)For anyone interested in the solution to this mediaOutput issue, I simply changed the JSF tag to use a key for the value instead of the entire byte array.
.xhtml file <a:mediaOutput element="img" cacheable="false" session="true" createContent="#{paintBean.paint}" value="#{logo.pictureKey}" mimeType="image/jpeg" rendered="#{logo.picture ne null}" />
Then, to get the actual byte array from the Seam managed backing bean into the PaintBean that was declared in the faces-config.xml file, I used the following code to set the newly uploaded image:Seam Backing Bean FacesContext.getCurrentInstance().getExternalContext().getSessionMap().put(getPictureKey(), picture);
and to retrieve it within the PaintBean after the mediaOutput tag passed in the key, I used:PaintBean managed outside of Seam public void paint(OutputStream out, Object data) throws IOException{ String pictureKey = (String) data; byte[] byteArray = (byte[]) FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get(pictureKey); out.write(byteArray); }