需要有关实现JSF ResourceHandler的教程 [英] Need tutorial on implementing a JSF ResourceHandler

查看:208
本文介绍了需要有关实现JSF ResourceHandler的教程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序需要实现动态图像,在浏览器中可以从数据库中获取JPG或PNG.

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

我一直正在读取该线程,但并没有得到很好的理解从中吸取教训.有人可以提供有关如何实现ResourceHandler的教程的链接.

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.

浏览了Amazon提供的有关JSF 2.0的所有书籍,似乎没有一个涵盖这个主题.预先感谢.

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

更新:因为我采用了另一种解决方案的途径,所以这个问题被取消了,该途径只是实现一个Servlet来提供图像.我要问的是如何使JSF Facelets Servlet响应具有"image/png"媒体类型的GET.尽管您似乎可以通过ResourceHandler工具来做到这一点,但我发现实现Servlet更容易,而且您在资源路径名方面也具有更大的灵活性.

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.

令我惊讶的是,尽管Servlet在处理请求时没有FacesContext,但是您可以注入由CDI管理的bean或资源.这给了我与应用程序其余部分相同的对JPA后端的访问权限.所以我的问题解决了.

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.

推荐答案

以下是指向不同方法的几个链接:

Here are several links to different approaches :

数据库中的JSF graphicImage-扩展资源

从数据库服务的ImageServlet

PrimeFaces-使用JSF的动态图像

这篇关于需要有关实现JSF ResourceHandler的教程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆