I have a scenario where I have to invoke another bean and registered bean attributes before rendering the JSF page as JSF page have reference to bean attributes for rendering response.
I am looking for best option to implement such scenario. I tried to represent required scenario in form of pseudo-code for better understanding.
Page A --> have button "View Detail" bind with BeanOne.getDetail() -- Scope is session.
BeanOne.getDetail()
process the request - call the backend method to get detail - if (type == XYZ) then invoke BeanTwo.getTypeXYZ() and redirect as per navigation rule defined for BeanTwo.getTypeXYZ() - else if (type == RST) then invoke BeanThree.getTypeRST() and redirect as per navigation rule defined for BeanThree.getTypeRST()
BeanTwo.getTypeXYZ()
- process the request
- call the backend method to get detail
- set this.attributeB = value returned from backend method.
- navigate to Page B
BeanTwo.getTypeRST()
- process the request
- call the backend method to get detail
- set this.attributeC = value returned from backend method.
- navigate to Page C
Something like having bean method name in navigation rule
<navigation-rule>
<from-view-id>Page A</from-view-id>
<navigation-case>
<from-action>#{beanOne.getDetail}</from-action>
<from-outcome>xyz</from-outcome>
<to-view-id>#{beanTwo.getTypeXYZ}</to-view-id>
</navigation-case>
<navigation-case>
<from-action>#{beanOne.getDetail}</from-action>
<from-outcome>rst</from-outcome>
<to-view-id>#{beanTwo.getTypeRST}</to-view-id>
</navigation-case>
</navigation-rule>