我有以下输出链接,它可以完成它的工作:
gets.chomp
它打开一个在新窗口中作为bean属性获取的URL。
但是,我想将链接转换为PrimeFaces中的按钮,感觉不错。我尝试如下:
<h:outputLink value="#{verDocumentoController.url()}" target="_blank">
show document
</h:outputLink>
但它只在新窗口中重新打开当前页面而不是指定为bean属性的URL。我怎么能实现这个呢?
答案 0 :(得分:10)
<p:commandButton>
基本上向其父<h:form>
指定的URL提交POST请求,该请求默认为当前请求URL(您知道,“回发”)。 action
属性基本上调用bean方法,并使用返回的值作为导航案例结果。 URL不一定代表合理的导航案例结果。
只需在简单的window.open()
上使用<p:button>
。
<p:button value="show document"
onclick="window.open('#{verDocumentoController.url()}');return false;" />
您也可以在<p:commandButton>
上执行此操作,但这不必要地过于复杂。