Need tutorial on implementing a JSF ResourceHandler

社会主义新天地 提交于 2020-01-26 04:07:28

问题


My application needs to implement dynamic images, where a browse can get served a JPG or PNG out of my data base.

I have been reading this thread and am not getting very far in learning from it. Can someone provide a link to a tutorial about how to implement a ResourceHandler.

Having looked through all the books Amazon offers on JSF 2.0, none of them seem to cover this topic. Thanks in advance.

UPDATE: This question is withdrawn since I took a different path to the solution, which was simply to implement a Servlet to serve up the images. What I was asking was how to get the JSF Facelets Servlet to response to a GET with a "image/png" media type. Although it seems that you can do that through the ResourceHandler facility, I found that implementing a Servlet is easier, and what's more you have more flexibility with regard to the resource path name.

What I was also surprised about is that although the Servlet doesn't have a FacesContext when it processes a Request, you CAN inject beans or resources that are CDI managed. This gave me the same access to the JPA back end as the rest of the application. So my issue is resolved.


回答1:


Here are several links to different approaches :

JSF graphicImage from database - Extending the Resource

ImageServlet serving from database

PrimeFaces - Dynamic Images with JSF



来源:https://stackoverflow.com/questions/10069181/need-tutorial-on-implementing-a-jsf-resourcehandler

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!