简体   繁体   English

分页后如何刷新jsf页面

[英]How to refresh jsf page after pagination

I have created selectALL checkbox functionality in jsf + icefaces. 我已经在jsf + icefaces中创建了selectALL复选框功能。 and i have implemented functionality like when i check selectAll checkbox it is selecting all the checkboxes across all the pages. 并且我实现了功能,例如当我选中selectAll复选框时,它选中了所有页面上的所有复选框。 but when i do pagination and if i do checked/unchecked select all checkbox then its works for only that page not acorss all the pages. 但是,当我进行分页并且如果我选中/未选中时,选中所有复选框,则仅适用于该页面的工作不匹配所有页面。 i mean the state of row checkboxes is not consistent. 我的意思是行复选框的状态不一致。 i tried phaseListener for solving this but no luck.. can anyone suggest me the solution.. 我试图用phaseListener解决这个问题,但是没有运气。

my code : jsf 我的代码: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: Java的

    if (shipTrackingData != null) {

                if (shipTrackingData.getCheckAll()) {

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

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

                        check.setCheckBox(false);
                    }
                }
            }

Thanks... 谢谢...

I have tested this code for a JSF application, I have three pages: 我已经为JSF应用程序测试了此代码,共有三页:

index_1.xhtml index_2.xhtml index_3.xhtml 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....
}

In each page I created two checkboxes one of them is to be selected across all pages if selected in any of them, but that checkbox is related to the same value (challval) for all pages. 在每个页面中,我创建了两个复选框,如果在其中任何一个页面中都选中该复选框,则将在所有页面中选中其中一个复选框,但是该复选框与所有页面的相同值(具有挑战性)相关。 there is also another checkbox for the page itself, one for each (chval1,chval2,chval3). 页面本身还有一个复选框,每个复选框(chval1,chval2,chval3)。

To test this I wrote this xhtml code for every page but you need to change the values according to each page, here is the code for index_1.xhtml, you need to change "go to" links to be able to access other pages: 为了对此进行测试,我为每个页面编写了此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>

I see no problem here, and when I check "select all" in one page, it is still checked in the others, I think the idea is to connect the "select all" checkbox with same bean value for all pages. 我在这里看不到任何问题,当我在一个页面中选中“全选”时,在其他页面中仍选中了它,我的想法是将“全选”复选框与所有页面的bean值连接在一起。 Hope this is useful, thanks. 希望这是有用的,谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM