0

休日の遅延読み込みデータを実装しました。より多くのデータをロードする必要がある瞬間に remoteCommand を使用すると、変数にはまだ初期値があります。load func でデータを出力しても正しく出力されますが、func が終了した後、値はメッセージやエラーなしで init から古い値にロールバックされます。コード:

@SessionScoped
@Named 
public class CalendarBean implements Serializable {
    private static String freeDays; //it should be static ?? without static the init func dont update there data. 

    public  String getFreeDays() {
         return freeDays;
    }

    public  void setFreeDays(String freeDayss) {
        this.freeDays= freeDayss;
    }

    public void loadDataFromDB(){
         freeDays=freeDays+//DB query with more data lazyloading
         ...
         System.out.print(freeDays); // it prints updated value with more object, but when the functions finish and I print CalendarBean.freeDays in Jscript it haves value from the init ...
    }

    public void initDays(){
         freeDays=//DB query
    }
}

.xhtml

<h:inputHidden id="hiddenButton2" value="#{CalendarBean.freeDays}"/>
<p:remoteCommand name="updateDaysJS" actionListener="#{CalendarBean.loadDataFromDB()}"/> //on default it is asynchronous i supose

Javascript

jQuery(document).ready(function() {
    #{CalendarBean.initDays()}
});
someFunction(){
    updateDaysJS();//this func triggered when i need more data of days
    //i ve tried also document.getElementById('MyForm:hiddenButton2').value = updateDaysJS(); but still not works(i ve changed ofc return type etc when i used this one
}
4

0 に答える 0