JSF 2.0 pass data between beans (or pages?)

Several quick things come to mind :

  1. Perhaps you could have a single bean only for those related pages, using @SessionScoped or the shorter CDI's @ConversationScope, or and this is the best of the three, the DeltaSpike @ViewAccessScoped
  2. When clicking the button on page 1 where it'll take you to page 2, in the 1st bean, you can make use of Flash object to store objects you want to pass, and in the second bean's @PostConstruct method, you could get all the objects from the Flash object
  3. If you dont mind using session scope, you can still have 2 beans, and one bean can refer to another bean using the jsf way(@ManagedProperty), or the Java EE inject way(@Inject) or the spring way if you use spring (@Autowired)

Tags:

Jsf 2