1

I would like the index page to show a list of products directly, say top 10 newest or something. How do I do this? How do I get JSF to run a method in a backingbean on a GET request and display the results?

Daniel Widdis
  • 8,424
  • 13
  • 41
  • 63
KS1
  • 1,019
  • 5
  • 19
  • 35
  • 2
    I don't get... why do you need this redirection? Why don't you just prepare the data you want to display in your backingbean and .. display it in your view? – stg Nov 22 '12 at 11:44
  • Hmmm...preRenderView may be the answer, unless there are better suggestions. – KS1 Nov 22 '12 at 11:46
  • @Fant that's what I want to do, but if my view is in my welcome list, my app seems to go straight to the view, I need it to run the backingbean first, but think I have an idea how to do this with preRenderView in the .jsf file – KS1 Nov 22 '12 at 11:48
  • @Fant - yeah, I'm being stupid. Stuck in a Struts mentality at the moment, setting the list data I can call the data stright away with a simple #{indexView.indexListXYZ} or something. Cheers. – KS1 Nov 22 '12 at 11:56
  • Just do the job in bean's (post)constructor, yes :) – BalusC Nov 22 '12 at 12:13

1 Answers1

2

Create a request/session scoped bean, make the @PostConstruct update the properties with the data you want to show, access the properties from the JSF.

SJuan76
  • 24,532
  • 6
  • 47
  • 87