我的问题类似于issue 我有一个在XHTML中,它调用支持bean方法来调用一个带有预构建URL的新窗口。但我的问题是它没有打开URL。
我在XHTML中的代码在下面给出了
<h:commandButton style="margin-left:1em;width: auto; height: 20px;font-size:85%"
value="WebPhone" id="lwebpne"rendered="#{Bean.editCmdActionflg == true and (Bean.selectedSearchSysDetRow.isfeed != '1' or Bean.selectedOverviewDetails.webPheFlg == false)}"actionListener="#{Bean.webPhoneSearch}" >
<f:param name="lpid" value="lpid" />
</h:commandButton>
我的代码在支持bean中给出了
public void webPhoneSearch(ActionEvent event) {
logger.info("webPhoneSearch Method Enter ..");
String param = "";
Map<String, String> params = FacesContext.getCurrentInstance()
.getExternalContext().getRequestParameterMap();
if (params.get("lpid") != null) {
System.out.println("coming inside>>>>>");
// String t_lpid = params.get("lpid");
String t_lpid = selectedOverviewDetails.getLeadPrgMgrUid();
Matcher matcher = pattern.matcher(t_lpid);
if (matcher.matches()) {
param = "this values comes from UI ";
}
}
// below is a URL where the window will launch to show the details of a person which we are search for
Url = "http:// URL for searching a person in webphone" +param;
RequestContext.getCurrentInstance().execute(
"window.open('" + Url + "')");
logger.info("webPhoneSearch Method Exit ..");
}<br/>
我的问题是,当我点击<h:commandbutton>
时,<h:commandbutton>
没有打开新窗口,而是在当前窗口中重新打开同一页面
请让我知道您解决此问题的建议。
答案 0 :(得分:1)
正如@Alexandre所说,&lt; h:commandButton /&gt;没有taget属性。 使用&lt; h:commandLink /&gt;
<h:commandLink target="_blank"
style="margin-left:1em;width: auto; height: 20px;font-size:85%"
value="WebPhone" id="lwebpne"
rendered="#{Bean.editCmdActionflg == true and (Bean.selectedSearchSysDetRow.isfeed != '1' or Bean.selectedOverviewDetails.webPheFlg == false)}"
actionListener="#{Bean.webPhoneSearch}">
<f:param name="lpid" value="lpid"/>
</h:commandLink>
---更新:---
如果您想触发某些javascript事件,可以使用&lt; f:ajax /&gt;。我的样本如下。
<h:commandButton style="margin-left:1em;width: auto; height: 20px;font-size:85%"
value="WebPhone" id="lwebpne" rendered="#{Bean.editCmdActionflg == true and (Bean.selectedSearchSysDetRow.isfeed != '1' or Bean.selectedOverviewDetails.webPheFlg == false)}">
<f:ajax execute="@form" render="@form" listener="#{Bean.webPhoneSearch()}" onevent="eventListener"/>
</h:commandButton>
<h:outputScript>
function eventListener(data) {
if (data.status == "complete") {
<!-- YOUR WINDOW ADDRESS HERE -->
window.open('http://google.com', '_blank');
}
}
</h:outputScript>
但我不建议使用弹出窗口。因为所有浏览器都会阻止它们。我认为dialog framework或lightbox组件可能更有用。