簡體   English   中英

JSF 頁面到支持 bean 荒謬的延遲

[英]JSF Page to backing bean absurd latency

在我正在處理的系統中,我們有一個頁面,其支持 bean 實現 API 從系統的主要(用戶相關)數據庫以外的數據庫獲取數據,並將數據存儲在本地(在內存中)。

存儲的 object 的一部分是指向輔助系統相關頁面的鏈接(和 Javascript 函數)。

這是我來自 JSF 頁面的相關代碼;

<p:dataTable id="dtDemonstrativoBoletos" value="#{bean.boletos}" rowKey="#{boleto.link}"
widgetVar="dtDemonstrativoBoletos" var="boleto" 
selection="#{bean.boletoSelecionados}" rowIndexVar="#{boleto.link}">
    <p:autoUpdate />
    <p:column selectionMode="multiple" width="0" toggleable="false"/>
    <!-- columns -->
    <p:column width="24" style="padding-left:0;">
        <p:link href="#{boleto.link}" target="_blank" >
            <i class="fa fa-eye" style="color:darkslategrey;"/>
        </p:link> 
    </p:column>
    <p:ajax event="rowDblselect" listener="#{bean.redirecionarBoleto} update="dtDemonstrativoBoletos"/>
</p:dataTable>

支持bean方法;

public void redirecionarBoleto() throws IOException {
    try {
        if (!this.boletoSelecionados.isEmpty()) {
            PrimeFaces.current().executeScript(this.boletoSelecionados.get(0).getLinkJs());
        } else if (this.boletoSelecionado != null) {
            PrimeFaces.current().executeScript(this.boletoSelecionado.getLinkJs());
        }
        this.getBoletoSelecionado().redirecionarJavascript();
        /* the getBoletoSelecionado() method returns either the this.boletoSelecionado object
        or attributes the first element in the this.boletoSelecionados list to it, 
        just to be clear */ 
        this.boletoSelecionados = new ArrayList<Boleto>();
    } catch (NullPointerException ex) {
    } catch (Exception e) {
        // TODO: handle exception
    }
}

和 object class。

public class Boleto {
    private String situacao;
    private String descricao;
    private String codigoBoleto;
    private String codigoEntidade;
    private String link;
    private String linkJs;
    private Date dataVencimento;
/*getters and setters*/ 
    public void redirecionarJavascript() {
        PrimeFaces.current().executeScript(this.linkJs);
    }
}

API 將link屬性設置為帶有codigoBoletocodigoEntidade值的 parametrized.xhtml 以及帶有boleto.setLinkJs("window.open('" + boleto.getLink() + "')");linkJs屬性; .

現在進入問題:由於該鏈接在DataTable上很容易獲得,因此單擊它會在 1.12 和 1.48 秒內正確重定向到頁面(如預期的那樣)(從本地主機到生產服務器),而 ajax 事件最多需要 50 秒到達后盾 我什至不是在開玩笑。 一旦它到達 bean,處理實際方法需要零時間(最長的延遲是在我看到它到達斷點並按下“跳過”之間)和相同的時間 - 一秒半 - 到達其他頁面。

任何關於為什么我的頁面直接不想訪問代碼的建議都將受到熱烈歡迎。 此外, linkJs屬性是作為測試措施實現的,可以立即調用,但 ajax 在DataTable中看不到boleto變量——我得到一個PropertyNotFoundException或類似的東西。 此外,由於系統標准化,我需要它與rowDblselect一起使用。

關於“PropertyNotFoundException”問題。 這可能是因為該特定屬性缺少 getter 和 setter 方法,或者因為您沒有在 package 中創建 JSF 2.3 配置 class 。

import javax.enterprise.context.ApplicationScoped;
import javax.faces.annotation.FacesConfig;
import static javax.faces.annotation.FacesConfig.Version.JSF_2_3;

@FacesConfig(version=JSF_2_3)
@ApplicationScoped
public class ConfigurationJSF {

}

那是JSF 2.3的配置

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM