Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

jsf 2 - graphicimage not rendering streamedcontent in Primefaces

I'm using streamedcontent to render a byte sent from JSF then send it back as a streamed content as following:

<p:graphicImage value="#{manage.bytesToStreamedContent(car.image)}"/>

where image is the byte array of the image stored in the database

backing bean:

public StreamedContent bytesToStreamedContent(byte[] bytes)
{
    InputStream is = new ByteArrayInputStream(bytes);
    StreamedContent image = new DefaultStreamedContent (is, "image/jpeg");
    return image;
}

But I'm not getting the image in the JSF page. I got this message appearing in the server log:

WARNING: JSF1091: No mime type could be found for file dynamiccontent. To resolve this, add a mime-type mapping to the applications web.xml.

and:

SEVERE: Error in streaming dynamic resource.

can you please help me out here, I cant find any useful info regarding this issue

PS:

Im using the following libraries:

Mojarra 2.1.3

PrimeFaces 3.1.1

Glassfish 3.1

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Found where the problem was. The problem wasn't in the graphicimage. It was because the graphicimage tag is being loaded dynamically (similar issue when trying loading from datatable). Dynamic images cannot be rendered directly in datatable or datagrid. (Workaround is to assign a param and bring the images from the id).

However, the solution is here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...