2013-12-19 23 views
0

我需要完成的任務如下。我需要渲染一個按鈕,它在向外部第三方發送SOAP請求(單一登錄)之後獲取其目標URL,該按鈕返回要登錄的URL。我不希望我的頁面加載時間受限於此請求(這是我現在堅持)。相反,我希望SOAP請求僅在單擊按鈕(異步)時纔會發生,這會將我帶到在新標籤頁/窗口中獲取的URL。我已經嘗試了一堆東西,但到目前爲止,我有這個:點擊後從loadbean加載外部url並重定向<p:button>

<p:button id="ssi" target="_blank" href="#{backbean.soaprequest}" value="button name" widgetVar="ssiButton" onclick="ssiButton.disable()" /> 

然而,這將等待soaprequest完成,然後完成呈現頁面。

我試過使用,但我無處可去。

你的幫助是非常讚賞

回答

0

你能做到這樣

按鈕

<p:commandButton value="Login" 
       actionListener="#{backbean.soaprequest()}" 
       oncomplete="handleComplete(xhr, status, args)" /> 

soaprequest()

public void soaprequest() { 
    //do your request, replace the link bellow with your login link 
    RequestContext context = RequestContext.getCurrentInstance(); 
    context.addCallbackParam("url", "http://google.com");//to replace with your link 
} 

JS

function handleComplete(xhr, status, args) { 
    window.location = args.url;  
} 

希望這會有所幫助。

在XHTML部分
+0

謝謝,但我得到了NPE - 在com.stratahealth.shared.common.services.impl.ClauseServiceRequestCache.compoundClauseForServiceProvider( ClauseServiceRequestCache.java:214) – allegjdm93

+0

以及這是不相關的,似乎你有一個服務提供商的問題..和服務提供商是這個http://stratahealth.com/ –

+0

即時通訊不知道這是怎麼回事這個問題,但我感謝t提出了一個解決方案他的帖子http://kahimyang.info/kauswagan/code-blogs/1166/speed-up-primefaces-page-load-with-premotecommand-partial-update – allegjdm93

0

我有

<p:outputPanel autoUpdate="true" layout="inline"> 
    <p:button id="ssibutton" target="_blank" href="#{backbean.link}" value="Button"/> 
</p:outputPanel> 

<p:remoteCommand name="soap_request" 
    process="@this" 
    update="ssibutton" 
    actionListener="#{backbean.url}" /> 

<script type="text/javascript"> 
    $(document).ready(function() {soap_request();});    
</script> 

在Backbean

private String url; 

public Backbean(){ 
    url = " "; 
} 

public String getLink(){ 
    return url; 
} 

public void url(ActionEvent event){ 
    //Do soap request to get url 
    this.url; 
}