问题标签 [graphicimage]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
jsf - p:graphicImage 不会改变值
我一直在尝试根据字符串参数显示一些图像。
我正在使用 java、Jboss、JSF 和 primefaces。图像在这里: ...Desktop\wildfly-10.0.0\bin\img\ 我使用以下路径: 将新餐厅加载到应用程序时保存图像 客户端显示餐厅时加载图像。
我正在使用的代码:
托管豆
xhtml页面:
当我调试它时,方法 loadImage 工作正常(添加具有正确名称和图像映射路径的不同图像),但是当我在 webbrowser 上看到页面时,我总是看到相同的图像。我使用“检查元素”选项来查看详细信息,并且图像在网络浏览器上始终具有相同的 src:
我不知道为什么当 bean 方法返回正确的值时会发生这种情况。
代码中使用的 ManagedBeans 具有会话范围。我使用了所有范围并使用了一些属性:cache="false"
,更改了value
forname
属性,但我无法解决问题。非常感谢
jsf - 在循环的每次迭代中将参数传递给方法
我正在尝试循环的每次迭代以获取要显示的数据。
xhtml
动物豆
是否可以以某种方式将参数传递给方法,以便在每次迭代时执行获取数据的方法?
jsf - 单击图像打开 p:fileUpload 的文件浏览面板
有什么方法可以<p:fileUpload>
在单击图像时触发基本按钮(显示面板以选择文件的按钮)?
jsf - 使用 @PostConstruct 迭代加载图像
我有两个文件 [index.xhtml, details.xhtml]
索引.xhtml
details.xhtml(在他想通过下载地址的参数 id 去的详细信息的页面上 - 向某人发送链接的能力)
项目豆
ItemDetailsBean
在 index.xhtml 中,我想循环显示图像。当用户点击图片时,我想重定向到包含所选图片详细信息的页面。 Id 必须在参数中传递 - 将允许它将链接发送给朋友。
image - 单击缩略图时打开原始图像
<p:graphicImage>
使用如下显示图像。
ImageBean
如下所示。
该service.findImageById()
方法返回byte[]
根据给定尺寸调整给定图像大小后获得的一个。
这将根据给定的尺寸在服务器端调整大小后显示缩略图。
<p:graphicImage>
动态生成要分配给src
生成的<img>
标签的图像 URL。这看起来像下面这样。
是否可以在新选项卡中打开原始图像,当单击拇指图像以便它可以对应于 HTML 时,如下所示?
在 JSF / PrimeFaces 的上下文中,它的值是什么href
以及<a>
如何动态分配?href
jsf - Prevent o:graphicImage from throwing an exception, when parameters being passed to a target getter method get mismatched in number, order and type
Using <o:graphicImage>
to display images with three parameters namely id
, width
and height
as follows.
The bean getting images:
The URL generated by <o:graphicImage>
looks like the following.
This works perfectly fine unless any parameter of wrong type, which is not convertible to a target type given as a method parameter, is attempted (perhaps by malicious users) like abc
in which case, it causes the following exception to be thrown.
This will lead to a global error page, if configured properly but I expect the exception should be transparent to the application program responsible for serving images from the associated database or disk file system.
Or the method parameters should be left to their default values. In my case, height
and width
are optional and if absent then, the image from the associated database should be rendered as it is without resizing or scaling.
But if height
and / or width
(or any other parameter) is absent then, an exception like the following is reported.
It is OmniFaces 2.3 final.
jsf - PrimeFaces 6.0 不在客户端缓存图像
给定<p:dataTable>
其中一列中的渲染图像。
数据表可以在需要时包含其他基本的常用属性和列。
当这个表被(Ajaxically)更新时,所有图像都从数据库(或磁盘文件系统,如果使用)中获取,就好像它们根本没有被浏览器缓存一样,即使cache
显式设置为true
(这是默认值)。这在 PrimeFaces 5.3 final 之前运行良好。
迁移指南对此没有任何说明,但显然缓存方面有所改变<p:graphicImage>
。
有什么建议可以解决这个问题吗?
在上面的示例中,如果表在 5 行中包含 5 个图像,例如,数据库将在每次更新时查询 10 次<p:dataTable>
(除了默认为当前行的内联行编辑)尤其是来自数据库的图像非常昂贵。
使用 PrimeFaces 6.0 最终版(在 WildFly 10.0.0 最终版上运行)的请求/响应标头,当向服务器发出初始请求以提供图像时(不起作用 - 图像未缓存)。
使用 PrimeFaces 5.3 final(在 GlassFish 4.1 上运行)的请求/响应标头,当向服务器发出初始请求以提供图像时(按预期工作 - 图像被缓存)。
jsf - 在 p:graphicImage 预览中显示 p:fileupload 图像而不保存它
我正在使用 PrimeFaces 5.3<p:fileUpload>
上传 PNG 图像,我想<p:graphicImage>
在保存到数据库之前显示它的预览。
这是一个 MCVE:
backing bean 上没有错误发生,并且图像不会在前端加载和显示。客户提到图像返回 404 not found 错误。
jsf - 如何创建指向 OmniFaces graphicsImage 方法的缩略图链接
我想知道是否以及如何<o:graphicImage>
在<p:lightbox>
. 更准确地说,我想实现这样的目标:
这显然不起作用,因为没有将正确的 URL 传递给灯箱。
imageBean.getFirstImage(Article article, boolean thumbnail)
返回byte[]
图像的 a,因为我要访问的图像存储在外部源上。
编辑:所以我已经按照 BalusC 提到的那样做了,这似乎是正确的方法。但是现在我遇到了以下异常:
这是实际返回图像的方法。它在其他所有情况下都可以正常工作:
编辑2:正如评论中提到的,我面临着另一种奇怪的行为。它在我的本地机器上运行得非常好,但在服务器上它抛出以下异常: