2014-01-23 2 views
1

JSF에서 <p:commandButton> 버튼을 클릭하여 새 팝업 창을 열려고합니다. 여기 JSF의 <p : commandButton>을 클릭하여 새 창 열기

내 코드,

<h:inputText style="width:42%"value="#{xxbean.values}" rendered="#{xxBean.yy == true}" 
    onblur="cc;" maxlength="6"> 
</h:inputText> 
<p:commandButton value="FindPhone" id="xxne" actionListener="#{xx.findPhoneSearch}" 
    oncomplete="window.open('#{xx.wpUrl}', '_blank')" 
    rendered="#{xx.editCmdActionflg == true }" async="false"> 
    <f:param name="pmid" value="#{xx.Details.uid}"/>         
</p:commandButton> 

내가 여기

가 findPhoneSearch 방법입니다 명령 단추 내부의 ActionListener에 위에서 주어진 같은 findPhoneSearch, 그 메소드를 호출하고있다

public void FindphoneSearch(ActionEvent event) { 



     String param = ""; 

     Map<String, String> params = FacesContext.getCurrentInstance() 
       .getExternalContext().getRequestParameterMap(); 

     String expression = "^[a-z0-9]+$"; 
     Pattern pattern = Pattern.compile(expression); 

     if (params.get("pmid") != null) { 
      String t_pmid = params.get("pmid"); 
      Matcher matcher = pattern.matcher(t_pmid); 
      if (matcher.matches()) { 
       param = "/cgi-bin/Findphones.pl?id=" + t_pmid.trim(); 
      } 
     } 

     if (params.get("lpid") != null) { 
      String t_lpid = params.get("lpid"); 
      Matcher matcher = pattern.matcher(t_lpid); 
      if (matcher.matches()) { 
       param = "/cgi-bin/Findphones.pl?id=" + t_lpid.trim(); 
      } 
     } 

     String findphoneUrl= "http://Findphone.com" + param; 
     wpUrl = findphoneUrl; 


    } 

내 문제는 wpurl에 할당 된 프레이밍중인 URL을 통과하지 않고 창이 비어있는 것입니다.

이 문제를 해결하는 데 도움을주십시오.

+0

commandButton에 update = "@ all"속성을 추가해보십시오. 귀하의 문제는 응답으로보기를 업데이트하지 않고 아약스 호출을 사용하려고하므로 wpUrl의 값이 오래되었다는 것입니다 (비어 있음). – Yamada

+0

@yamada : 나는이 코드를 사용하여 backing bean에 매개 변수를 전달하려고합니다. 명령 단추를 클릭하지만 값을 가져올 수 없습니다. – techy360

답변

1

PrimeFaces 구성 요소의 EL #{...}oncomplete 속성은 단추가 표시된 페이지가 처음 표시 될 때 평가되며 단추를 누른 후에는 평가되지 않습니다. 기본적으로 액션 메소드에서 변경된 값이 아니라 페이지가 렌더링되는 동안의 값을 처리합니다.

oncomplete을 수행하는 대신 인라인 스크립트를 ajax로 업데이트하는 것이 좋습니다.

<p:commandButton ... update="openWindow" /> 
<h:panelGroup id="openWindow"> 
    <h:outputScript rendered="#{not empty xx.wpUrl}"> 
     window.open('#{xx.wpUrl}', '_blank') 
    </h:outputScript> 
</h:panelGroup> 

버튼에서 async="false"을 반드시 삭제하십시오.

+1

그게 효과가! BaluC에 감사드립니다 !! – techy360

+0

당신을 진심으로 환영합니다. – BalusC