If I have a list like : List<NewsItems>
, and there are 10 news items in this list, is there some way I can get a set of 4 different news items each time, for instance, say the 1st, 4th, 8th and 10th item in the list.
I am currently using Pageable Collections and breaking up the display of news items to show 4 news items ( max ) per page. So, in this way, I can randomly change the page to display ( thus ultimately changing the news at every refresh) , but it is not random per news item ( for eg : 1-4 items are always together , as are 5-8 ).
final HippoResultSetBean resultSet = featurednewsBean.getResultSet();
if (resultSet != null && resultSet.getCount() > 0) {
final HippoDocumentIterator<NewsDocument> facetIt = resultSet.getDocumentIterator(NewsDocument.class);
final int facetCount = featurednewsBean.getCount().intValue();
/*
* @ Javadoc - Show news items(max 4) randomly at every page refresh.
* FacetCount - No. of news items.
* pageRandom - A randomly generated number for the current page, so that we display a different page containing news each time.
*/
int pageRandom = (int) (Math.random() * facetCount);
//if(pageRandom<(facetCount/4)+1) {
featurednews = new PageableCollection<NewsDocument>(facetIt, facetCount, DEFAULT_HEADLINES_MAX,pageRandom);
Is there a way that I can still use Pageable Collections and randomly get the news feed ? OR some other way? Any help is greatly appreciated.