Wednesday, December 14, 2011

Creating a simple frontpage news display - Primefaces

I was working on a project today in which I was requested to create a simple news display in our application's frontpage, so I used the toggleable feature in Primefaces panels and some javascript to achieve this. the result looks like the following:






To do this, I created a request scoped bean which retrieved the news records that I wanted to display in the frontpage




In the xhtml page I did the following:


  • Used ui:repeat to create multiple panels based on the news count
  • Set the toggleable attribute to true
  • Set the collapsed attribute of the first panel to true and the rest to false
  • Created a timer which calls a function which invokes the "toggle()" function of the opened panel and the next panel, this timer is run on page load
here is the code:


No comments:

Post a Comment