亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在java類中將文檔設置為全局屬性,不起作用

在java類中將文檔設置為全局屬性,不起作用

慕勒3428872 2021-12-01 15:00:05
在我的 Xpages 應用程序中,我有一個 java 類,我想在其中將 Document 設置為全局屬性并在我的方法中重用。該文檔代表一個 Notes 配置文檔,我只想執行一次查找。不幸的是,它沒有按預期工作。也許有人可以指導我正確的過程?首先,我設置了一個托管 bean:<managed-bean>    <managed-bean-name>emplDataMining</managed-bean-name>    <managed-bean-class>se.bank.employeeApp.utils.EmployeeDataMining</managed-bean-class>    <managed-bean-scope>view</managed-bean-scope></managed-bean>我的課程包含幾種將轉到不同系統的方法。系統的所有 URL 都存儲在 Notes 配置文檔中,我只想加載一次并在這些方法中重復使用public class EmployeeDataMining implements Serializable{    private static final long serialVersionUID = 1L;    private Document configuration;    //constructor class. not so very special, so I wont post it    public void getConfiguration(){        //setting up database and view        //only 1 document stored in the view so I can hard-code the reference        configuration = vw.getDocumentByKey("ConfigDocument", true);        //... rest of code e.g. setting up httpclient, JSONobj    }    public void collectDataFromSystemX(CloseableHttpClient httpclient, Employee employee, JSONObject JSONobj){        //I wont post all of my code          HttpPost httpPost = new HttpPost(this.configuration.getItemValueString("urlSystemX"));        //this.configuration is null :-?        //..rest of code    }    public void collectDataFromSystemY(CloseableHttpClient httpclient, Employee employee, JSONObject JSONobj){        //I wont post all of my code          HttpPost httpPost = new HttpPost(this.configuration.getItemValueString("urlSystemY"));        //this.configuration is null :-?        //..rest of code    }}我的代碼是從 SSJS 發起的:emplDataMining.getConfiguration(); emplDataMining.collectDataFromSystemX(//passing in the variables which are setup in getConfiguration method)所以我主要擔心的是配置文件 Document 沒有正確設置或在方法之間交換。有人能告訴我我忽略了什么嗎?
查看完整描述

1 回答

?
天涯盡頭無女友

TA貢獻1831條經驗 獲得超9個贊

有2個問題:

  • 在視圖范圍內,您打開的每個文檔都會重新加載 bean。如果它是一個配置文件,你想使用會話范圍

  • 您不能在托管 bean 中存儲 Notes 對象(請求范圍可能有效)。你做什么:在你的 bean 的構造函數中,加載文檔并將字段值提取到 bean 內部變量(字符串、列表等)中。那會給你你想要的


查看完整回答
反對 回復 2021-12-01
  • 1 回答
  • 0 關注
  • 224 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號