使用自定义组件在 JSF 中创建弹出窗口

发布于 2024-12-19 00:55:38 字数 573 浏览 2 评论 0原文

如果我在 JSF 页面上创建弹出窗口,我需要使用一个自定义组件。 它似乎使用了带有 CSS 隐藏和显示的 DHTML 技术,并在当前页面上创建了一个覆盖层,而不是一个正确的窗口。

就我而言,它是显示由 servlet 提供服务的图像。

我尝试了几件事,结果如下: 1)如果我使用 弹出窗口和图像会显示然后消失,因为 commandButton 会刷新页面。

2) 如果我将 commandButton 的类型更改为“button”,则操作字段中的 bean.displayImage 永远不会被调用,servlet 也不应该提供图像

3) 我还尝试将bean.displayImage 在 actionListener 字段中,并通过添加 ActionEvent e 作为参数来修改方法以防止页面刷新,但它的行为与 2) 我已经

没有想法了,可以有人帮忙吗?

提前致谢, 迈克尔

I've got a custom component that I need to use if I create a popup on a JSF page.
It seems it uses the DHTML technique with CSS hide and show and creates an overlay on the current page, and not a proper window.

In my case, it's to display an image that is served by a servlet.

I have tried several thing and here are the results:
1) if I use <h:commandButton action="bean.displayImage" onclick="mypopup.show()"> the popup and image are displayed then disappear because the commandButton refreshes the page.

2) if I change the type of the commandButton to "button", then bean.displayImagein the action field is never called, neither is the servlet supposed to serve the image

3) I also tried putting the bean.displayImage in the actionListener field and modifying the method by adding ActionEvent e as param to prevent the page from refreshing, but it then has the same behavior as 2)

I'm running out of ideas, can anyone help ?

Thanks in advance,
Michael

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深海不蓝 2024-12-26 00:55:38

功能需求并不完全清楚,但您可以使用 使其成为 ajax 请求并呈现页面的某些部分。

像这样的东西:

<h:commandButton value="Show popup" onclick="mypopup.show()">
    <f:ajax listener="#{bean.displayImage}" render="image" />
</h:commandButton>
<h:panelGroup id="image">
    <h:graphicImage value="imageURL" rendered="#{bean.renderImage}" />
</h:panelGroup>

The functional requirement is not entirely clear, but you could use <f:ajax> to make it an ajax request instead and render certain parts of the page.

Something like:

<h:commandButton value="Show popup" onclick="mypopup.show()">
    <f:ajax listener="#{bean.displayImage}" render="image" />
</h:commandButton>
<h:panelGroup id="image">
    <h:graphicImage value="imageURL" rendered="#{bean.renderImage}" />
</h:panelGroup>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文