I have a scenario and dont have a clear idea for this to work yet.
Here's the example scenario :
- I have a myView.xhtml file that can be displayed as a window popup or a primefaces dialog popup from 2 other container xhtml, let's say container1.xhtml and container2.xhtml (the myView.xhtml is included with something like this ?
<ui:include src="myView.xhtml" />) - And, we also have the view-scoped beans, let's call them myViewBean, container1Bean and container2Bean
- container1Bean has the property of transactionDate, and container2Bean has a property of transDate
- myViewBean's @PostConstruct method will query the database based on a parameter of type date.
- On container1.xhtml, if a user clicks on a button that will popup the myView.xhtml, container1Bean should be able to provide it's transactionDate to the myViewBean, and myViewBean will be able to query based on it in the @PostConstruct method.
- On container2.xhtml, if a user clicks on a button that will popup the myView.xhtml, container2Bean should be able to provide it's transDate to the myViewBean, and myViewBean will be able to query based on it in the @PostConstruct method.
I was thinking about using @Inject Container1Bean and @Inject Container2Bean in the MyViewBean, so that inside MyViewBean, i can get the transactionDate of container1Bean or transDate of container2Bean. To decide which container bean is active is to check which one is not null.
But what if the container beans grows, there could be other container beans that make use of the MyViewBean, and the @Inject ContainerXXBean will grow in numbers inside the MyViewBean. There must be other solutions for this.
Please share ideas on how to accomplish this .. Thank you ! :-)
Thank you !