簡體   English   中英

分頁后如何刷新jsf頁面

[英]How to refresh jsf page after pagination

我已經在jsf + icefaces中創建了selectALL復選框功能。 並且我實現了功能,例如當我選中selectAll復選框時,它選中了所有頁面上的所有復選框。 但是,當我進行分頁並且如果我選中/未選中時,選中所有復選框,則僅適用於該頁面的工作不匹配所有頁面。 我的意思是行復選框的狀態不一致。 我試圖用phaseListener解決這個問題,但是沒有運氣。

我的代碼:jsf

<ace:column id="checkBox">
                                <f:facet name="header">
                                    <h:outputLabel>
                                        <ice:selectBooleanCheckbox id="selectAllID"
                                            value="#{shipBean.checkAll}"
                                            valueChangeListener="#{shipBean.getCheck}"
                                            partialSubmit="true" />
                                    </h:outputLabel>
                                </f:facet>
                                <ice:selectBooleanCheckbox id="selectOne"
                                    value="#{freight.checkBox}">

Java的

    if (shipTrackingData != null) {

                if (shipTrackingData.getCheckAll()) {

                    for (ShipTrackBean check : shipTrackingData
                            .getShipTrackList()) {
                        check.setCheckBox(true);
                    }

                } else {
                    for (ShipTrackBean check : shipTrackingData
                            .getShipTrackList()) {

                        check.setCheckBox(false);
                    }
                }
            }

謝謝...

我已經為JSF應用程序測試了此代碼,共有三頁:

index_1.xhtml index_2.xhtml index_3.xhtml

@ManagedBean
@SessionScoped
public class pross {
    private boolean challval=false;
    private boolean chval1=false;
    private boolean chval2=false;
    private boolean chval3=false;
.. getters and setters....
}

在每個頁面中,我創建了兩個復選框,如果在其中任何一個頁面中都選中該復選框,則將在所有頁面中選中其中一個復選框,但是該復選框與所有頁面的相同值(具有挑戰性)相關。 頁面本身還有一個復選框,每個復選框(chval1,chval2,chval3)。

為了對此進行測試,我為每個頁面編寫了此xhtml代碼,但是您需要根據每個頁面更改值,這是index_1.xhtml的代碼,您需要更改“轉到”鏈接才能訪問其他頁面:

 <h:body>
        <h:form>
        Hello, Test checkboxes:
        <br />
        Select this page: <h:selectBooleanCheckbox value="#{pross.chval1}" >
            <f:ajax render="outthis outall"/>
        </h:selectBooleanCheckbox>
        This page select: <h:outputText id="outthis" value="#{pross.chval1}"/>
        <br/>
        Select all pages: <h:selectBooleanCheckbox value="#{pross.challval}">
            <f:ajax render="outthis outall"/>
        </h:selectBooleanCheckbox>
        all pages select: <h:outputText id="outall" value="#{pross.challval}"/>
        <br/>
        <h:link outcome="index_2" value="Go to page 2" />
        <br/>
        <h:link outcome="index_3" value="Go to page 3" />
        </h:form>
    </h:body>

我在這里看不到任何問題,當我在一個頁面中選中“全選”時,在其他頁面中仍選中了它,我的想法是將“全選”復選框與所有頁面的bean值連接在一起。 希望這是有用的,謝謝。

暫無
暫無

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

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