在 a4j:commandButton 中打开一个新窗口
在 Web 应用程序中使用 A4J、Richfaces,当用户单击
时,我需要打开一个新的浏览器窗口。
我想我必须使用 window.open(URL, ...)
。我应该把它放在哪里?
我的
看起来像这样:
<a4j:commandButton id="elementDetailsButton"
onclick="if (!confirm('Are you sure? Unsaved data will be lost')) { return false; }"
action="#{myBean.elementDetailsAction}"
value="Element Details">
<a4j:actionparam name="elementDetailsString"
value="getElementDetails()"
assignTo="#{myBean.elementDetails}" noEscape="true">
</a4j:actionparam>
</a4j:commandButton>
Using A4J, Richfaces in a web application, I need to open a new browser window when the user clicks on the <a4j:commandButton>
.
I think I will have to use window.open(URL, ...)
. Where should I put it?
My <a4j:commandButton>
looks like this:
<a4j:commandButton id="elementDetailsButton"
onclick="if (!confirm('Are you sure? Unsaved data will be lost')) { return false; }"
action="#{myBean.elementDetailsAction}"
value="Element Details">
<a4j:actionparam name="elementDetailsString"
value="getElementDetails()"
assignTo="#{myBean.elementDetails}" noEscape="true">
</a4j:actionparam>
</a4j:commandButton>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以确认
window.open
而不是return false
“Else”是可选的,也许不是必需的。
或者您可以更改表单目标..我不太记得它的语法是否正确...
...或类似的东西。
改变表单目标会给你带来一个很好的问题。其余的应用程序将瞄准新窗口。为了解决这个问题,我做了一个
来关闭窗口 (modalPanel) 并重置表单目标。我使用这个(目标技巧)使用
在
中打开 .pdf 报告。但我不确定更改表单目标是否对您的问题有用。
You can confirm the
window.open
and not thereturn false
"Else" is optional, maybe not necessary.
Or you can change the form target.. I dont remember very well if its the correct syntax...
...or something like that.
Changing the form target will give you a nice problem. The rest of you application will target the new window.. To solve this problem, I made a
<h:commandLink/>
to close the window (modalPanel) and reset the form target.I was using this (the target trick) to open .pdf reports inside a
<rich:modalPanel/>
using a<iframe/>
.But I'm not sure if change the form target will be useful for your problem..
正如我从您的命令按钮中看到的,您想要请求确认、执行操作并打开一个新窗口,对吗?我不完全确定一个按钮是否可以处理这么多操作,但您始终可以尝试使用 onload 配置并将操作分配给要加载的页面,并允许commanbutton处理确认和打开窗口的操作,就像雷南提议道。
As I can see from your commandbutton you want to ask for confirmation, execute an action and open a new window right? I am not totally sure if a button can handle so many actions but you could always try to use onload configuration and assign an action to the page you want to load and allow the commanbutton to handle both confirmation and the action of opening the window just as Renan suggested.