> >>> Let JSF do the initialization stuff itself based on bean definitions > made in faces-config.xml. > > This doesn't allow me to specify a method call on Page2.java to run my > custom initialization logic. Yes, on page2.xhtml I would be able to > access properties from Page1.java but this isn't what I'm looking for. > I need to load other stuff in page2.xhtml based on data from page1.xhtml. > >>> A form can combine several beans or a bean can be used by > several forms. > > Agreed. And have used this numerous times in the app. But in a few > situations it makes more sense to have separate beans. I'm surprised > that there's no way to call custom initializers. In EJB there's a > @PostConstruct annotation that calls custom logic after the bean manager > creates the bean. > > Thanks for the ideas and help. Based on what you're saying it sounds > like there's no way to do what I'm looking to do? > > Later, > Ok sorry, I was not reading the thread fully, but what you want to do is to display data being loaded from a db on a page 2 depending on some states being passed down from page 1....
There are several ways to do this... Either go for a scoping system (aka one bean per multiple pages, which you obviously want to avoid)... which keeps the bean in the backend stateful, so everything you do in page1 is accessible in page2, you then can use various mechanisms to locate the state that page2 has been reached (the easiest one probably simply is to misuse the setters which are called very early, or you could write a phase listener triggering into your bean etc...) whatever, once you are in page2 you can reuse the values according to the state. Another solution: Use a simple view controller pattern (I really can recommend shale view controllers here, they give you the initial callbacks you need for a proper resolution, it delivers exactly the callbacks you said jsf was in need for, and I agree here with you 100%) pass the values needed from page1 to page2 (via: t:updateActionListener is probably the easiest way= and then use the view controllers callbacks to preload the data according to your state) Third solution, use a dialog system like shale or some scoping or flash system (savestate for instance) to keep the values you need to pass from page1 to page2 then you have the values available in page2 as well (probably savestate might be the easiest solution for this simple case) You still can use the view controllers for the defined page callbacks only the data which is passed from page1 to page2 has to be scoped. This runs like: run into the action, change the values on the savestated bean manually you want to set, then return the outcome, in page2 get the bean again via the variable resolver and then the values are available again. Alternatively you could use dialog systems as well to pass the values. (Shale dialog for instance has an object holer map which you can use) there are numerous other solutions to this problem but those probably are the ones which work best.

