0

私はこのようなから持っています

<h:form id="logForm" prependId="false">
    <div class="leftcol">
    ....
    <h:commandButton value="Apply Filters"
        action="#{exporterReview.applyFilterAction}">    
    </h:commandButton><br></br><br></br>
    ....
    </div>

    <div class="rightcol1" >
        <p:dataTable  var="exporter" 
                      value="#{exporterReview.exporters}"
                      paginator="true" rows="5"
                      height="400" paginatorPosition="top"
                      emptyMessage="#{exporterReview.noExporterFound}">

            <p:column>

                <div style="....">
                    <h:graphicImage value="#{exporter.imgPath}" />
                </div>

                <div style="...">
                    <h:commandButton value="Update" 
                                     action="#{exporterReview.updateExporter}"         
                                     rendered="#{login.updateState}"  
                                     style="... ">
                        <f:param name="exporterid" 
                                 value="#{exporter.exporterId}" />
                    </h:commandButton>
                </div>

                <div class="arrowbuttons">
                    <span class="arrow"></span>
                </div>
                <p:spacer height="10" width="20"/>
                <h:commandButton  value="#{exporter.organizationName}" 
                                  action="#{exporterReview.viewExporter}" 
                                  style="...">
                    <f:param name="exporterid" value="#{exporter.exporterId}" />
                    <f:param name="disableLink" value="#{exporter.disableLink}" />
                </h:commandButton>

                <div style='padding-top:10px'>
                    <h:outputLabel value="City: "  style="color: #1c6ace;"/>
                    <h:panelGroup rendered="#{not exporter.disableLink}">
                        <h:commandLink value="#{exporter.cityName}" 
                                       style="text-decoration: underline" 
                                       disabled="#{exporter.disableLink}" 
                                       onclick="openCityPopup(#{exporter.cityId});" >
                        </h:commandLink>
                    </h:panelGroup>

                    <h:panelGroup rendered="#{exporter.disableLink}">
                        <h:outputText value="#{exporter.cityName}"></h:outputText>
                    </h:panelGroup>
                </div>

                <div style='padding-top:3px'>
                    <h:outputLabel value="Email Address: " style="color: #1c6ace;"/>
                    <a href="mailto:#{exporter.emailAddress}">
                        <h:outputText value="#{exporter.emailAddress}" 
                                      style="..">
                        </h:outputText>
                    </a>
                </div>

                <div style='padding-top:3px'>
                    <h:outputText value="#{exporter.categoryDesc}" 
                                  escape="false" />
                </div>

                <div class="horizontalline"></div>
            </p:column>

        </p:dataTable>
    </div>
</h:form>

これがフィルター方法です

public void applyFilterAction() {
    ....
    //Setting whereParam so that whenever user navigate from page And return back
    // the grid is populated with the previous search criteria
    session.setAttribute("settingWhereParam", whereParam);
    getExporterGrid();

} //end of applyFilterAction

private void getExporterGrid() {
    ....
    exporters.add(new Exporter(Datatable values));

} //end of getExporterGrid

問題は、私が最初のページにいて検索を行うと、すべてが正常に機能することです。これが最初の写真です。 ここに画像の説明を入力してください

次に、検索を適用すると、次のようになります。

ここに画像の説明を入力してください

しかし、ページ付けを行う場合、たとえば4ページに移動して検索を適用すると、結果は表示されません。

ここに画像の説明を入力してください

しかし、その後は何も表示されません

ここに画像の説明を入力してください

なぜそれが起こっているのですか?私が間違っていることは何ですか?Primefaces2.2を使用しています。その古いプログラム。

ありがとうございました

4

2 に答える 2

0

やったよ :)。実際、私は回避策を実行しました。私がしたことは、フィルターボタンでonClickイベントを使用したことです。好き

<h:commandButton id="filterButton"
                 value="Apply Filters"
                 style=""
                 action="#{exporterReview.applyFilterAction}"
                 onclick="filterButtonClick(event)" />

ボタンがクリックされると、最初にクライアント側のコードが実行されます。したがって、すべての値を取得してから、ajaxを使用してサーブレットを呼び出し、結果をセッションオブジェクトに保存します。その後、サーバー側のコードが実行され、アクションメソッドが呼び出されます。このメソッドでは、同じページのURLを返すだけです。

public String applyFilterAction() {

    return "Exporter_Review?faces-redirect=true";

} //end of applyFilterAction()

これで、ページが呼び出されたときに、セッションで結果を確認するだけです。また、セッションオブジェクトが存在する場合は、そのオブジェクトから値を取得して結果を表示します。そして、ページを離れるとき、オブジェクトに対するセッションにnullを入れるだけで、デフォルトが使用されるようになりました。これですべてが正常に機能しています:)

于 2012-08-06T07:08:00.073 に答える
0

これが primefaces 2.2 で機能するかどうかはわかりませんが、バージョン 3 以降では update 属性を指定できます。

commandButton は次のようになります。

<h:commandButton value="Apply Filters" action="#{exporterReview.applyFilterAction}" update="@form">
于 2012-08-01T13:21:56.973 に答える