Question

I have two region and two taskflow on a page. On first taskflow manage bean is on pageflow scope where in second taskflow its on backing bean scope. My requirement is I want to call method of one bean from econd bean and vice-versa.

For example: on first jsff if some action happen then it action will go to its bean and from there I need to call method of second bean and vice-versa.

How can I achieve this?

Since both task flow will be running at same time so I need to get running instance of bean so that I can get the current status/value UI components.

Was it helpful?

Solution

All you need to do is to inject the bean whose method you want to use in the other bean. In ADF there is an easy way to achieve this. You should have a file called adfc-config.xml inside your WEB-INF folder. If you open it's source, you'll notice that each bean is described inside the <managed-bean> tag. It will be something like:

<managed-bean id="__2">
    <managed-bean-name>bean1</managed-bean-name>
    <managed-bean-class>com.domain.Bean1</managed-bean-class>
    <managed-bean-scope>view</managed-bean-scope>
</managed-bean>

for each bean. You have to insert a <managed-property> tag inside with a reference of the bean you want to inject, just like this:

<managed-bean id="__2">
    <managed-bean-name>bean1</managed-bean-name>
    <managed-bean-class>com.domain.Bean1</managed-bean-class>
    <managed-bean-scope>view</managed-bean-scope>
    <managed-property>
        <property-name>bean2</property-name>
        <value>#{Bean2}</value>
    </managed-property>
</managed-bean>

Also, inside the Bean1 class you have to create an instance variable of Bean2, and then you can use it to get its current state.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top