views:

32

answers:

2

I was wondering how could I be able to show users warning or information to refine the search if their search result exceeds 100. For example: if the search results are more than 100 then display only hundred and show users warning to refine the search, in JSF/datatable.

Any help would be highly appreciated. Thanks

+2  A: 

You can do the following:

  • limit the list size in your managed bean. Preferably, set a limit to the SQL result (or whatever persistence mechanism you are using)
  • set a boolean shouldRedefineCriteria (in the managed bean) in case the result is bigger than 100. If you have limited the SQL result, you can safely specify:

    shouldRedefineCriteria = result.size() >= 100;
    
  • in your jsf page output:

    <h:outputText value="Redefine your criteria" 
         rendered="#{managedBean.shouldRedefineCriteria" />
    
Bozho
Thanks for your time.I am using JPA.
then use `query.setMaxResult()` to limit the result of the query
Bozho
A: 
query.setMaxResults(4);

I think i got it.

Thanks....