java - JSF- <h:commandButton> does not invoke new window from backing bean -
my issue similar issue
having in xhtml , calls backing bean method invoking new window pre constructed url.but problem not opening url.
my code in xhtml given below
<h:commandbutton style="margin-left:1em;width: auto; height: 20px;font-size:85%" value="webphone" id="lwebpne"rendered="#{bean.editcmdactionflg == true , (bean.selectedsearchsysdetrow.isfeed != '1' or bean.selectedoverviewdetails.webpheflg == false)}"actionlistener="#{bean.webphonesearch}" > <f:param name="lpid" value="lpid" /> </h:commandbutton>
, code given in backing 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 ui "; } } // below url window launch show details of person search url = "http:// url searching person in webphone" +param; requestcontext.getcurrentinstance().execute( "window.open('" + url + "')"); logger.info("webphonesearch method exit .."); }<br/>
my problem clikcing <h:commandbutton>
not open new window instead same page reopens in current window when click <h:commandbutton>
please let me know suggestions resolve issue.
as @alexandre say, <h:commandbutton/> doesn't have taget attribute. use <h:commandlink/>
<h:commandlink target="_blank" style="margin-left:1em;width: auto; height: 20px;font-size:85%" value="webphone" id="lwebpne" rendered="#{bean.editcmdactionflg == true , (bean.selectedsearchsysdetrow.isfeed != '1' or bean.selectedoverviewdetails.webpheflg == false)}" actionlistener="#{bean.webphonesearch}"> <f:param name="lpid" value="lpid"/> </h:commandlink>
--- update: ---
if want trigger javascript events can use <f:ajax/>. sample below.
<h:commandbutton style="margin-left:1em;width: auto; height: 20px;font-size:85%" value="webphone" id="lwebpne" rendered="#{bean.editcmdactionflg == true , (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") { <!-- window address here --> window.open('http://google.com', '_blank'); } } </h:outputscript>
but don't advise use popup window. because of browsers block them. think dialog framework or lightbox component can more useful.
Comments
Post a Comment