简体   繁体   English

jsf primefaces过滤分页范围

[英]jsf primefaces filtering pagination scope

i am filtering my columns and have used pagination so i have made my backing bean session scoped, i have also made it session scoped because i am loading data from db n dont want it to reload. 我正在过滤我的列并使用了分页功能,所以我将我的backing bean会话设置为作用域,因为我正在从db加载数据,所以我也将其设置为会话作用域n不想重新加载它。 i am using a view button to select a column and forwarding to a new page to display further information and am using a back button there to return back to the main page. 我正在使用查看按钮来选择一列,并转发到新页面以显示更多信息,并且正在使用后退按钮返回到主页。

now my problem is that when i filter my data and hit the view button it shows me the data but when i hit the back button n it goes back to the main page the data is still filtered, i know this is happening cauz i have used session scope n the filtering is persisting. 现在我的问题是,当我过滤数据并单击查看按钮时,它向我显示数据,但是当我单击后退按钮n仍返回到主页时,数据仍在过滤,我知道这是正在发生的问题,因为我已经使用过会话范围n过滤持续存在。 The problem with this is that even thought the data is filtered it doesnt show the value in the filtering cell by which it is filtering. 这样做的问题是,即使认为数据已被过滤,它也不会在其进行过滤的过滤单元中显示该值。 to remove the filtering i have to enter a value into the filtering cell and remove it to get all the data back. 要删除过滤,我必须在过滤单元中输入一个值并将其删除,以取回所有数据。 i feel like maybe i have a design flaw but cant figure out how to solve it. 我觉得也许我有一个设计缺陷,但无法弄清楚如何解决它。

code snippet 程式码片段

main page 主页

 <p:dataTable var="curridea" value="#{userIdea.ideas}"   filteredValue="#{userIdea.filteredideas}"

    paginator="true" rows="10"  
                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                 rowsPerPageTemplate="5,10,15">


        <p:column headerText="Employee Name"  filterBy="empname"   

                filterMatchMode="contains">  
            <h:outputText value="#{curridea.empname}" />  
        </p:column> 
 <p:column headerText="View">  
            <h:commandButton value="view" action="#{userIdea.actionController}"  >
            <f:setPropertyActionListener value="#{curridea}" target="#{userIdea.selectedidea}" />  

            </h:commandButton> 
        </p:column>  

view page 查看页面

<h1 class="title">Your idea Here</h1>
<h:form>
<h:outputText value="#{userIdea.selectedidea.idea}" escape="false" />

<h:commandButton value="back" action="#{userIdea.returnController}"  >


            </h:commandButton> 

useridea 用户理念

private ArrayList<Idea> filteredideas;

    public ArrayList<Idea> getFilteredideas() {
        return filteredideas;
    }

    public void setFilteredideas(ArrayList<Idea> filteredideas) {
        this.filteredideas = filteredideas;
    }

UPDATE: i solved it by setting the filtered idea in the view page back button to empty but pllease let me know if there is a better solution i am not seeing 更新:我通过将视图页面后退按钮中的过滤后的想法设置为空解决了问题,但请让我知道是否有更好的解决方案,但我没有看到

<h:commandButton value="back" action="#{userIdea.returnController}"  >

             <f:setPropertyActionListener value="" target="#{userIdea.filteredideas}" />   
            </h:commandButton> 

i solved it by setting the filtered idea in the view page back button to empty but pllease let me know if there is a better solution i am not seeing 我通过将“查看”页面“后退”按钮中的过滤后的主意设置为空解决了问题,但请让我知道是否有更好的解决方案,但我没有看到

<h:commandButton value="back" action="#{userIdea.returnController}"  >

             <f:setPropertyActionListener value="" target="#{userIdea.filteredideas}" />   
            </h:commandButton> 

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

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