wood burning stoves 2.0*
The moose likes JSF and the fly likes communication between 2 session beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "communication between 2 session beans" Watch "communication between 2 session beans" New topic
Author

communication between 2 session beans

Chad Foor
Greenhorn

Joined: Jul 03, 2007
Posts: 23
Hi,

I have a situation where it makes sense in the code to have 2 session beans declared in faces-config.xml to talk to one another.

The basic form stuff is declared in a session bean I call 'inputForm' (alias) and a helper bean called 'helper'. It makes sense to not have a concrete instance of the helper bean declared as an object within inputForm per se, but rather I need it to be called from my JSP page(s) directly. I just need to have 2 internal variables set between both the session beans using getters / setters.

How can I accomplish this ? (if it's possible ?)

Appreciate any help.

Thanks,
Chad
Majid Al-Fifi
Ranch Hand

Joined: Aug 22, 2006
Posts: 45
Are you aware you can "inject" one bean into another in faces-config.xml?

you can use helper directly in your jsp if you have defined it faces-config.xml as a managed bean and if helper needs something form another bean then inject that other bean into helper.

regards

Majid


SCJP1.4, SCWCD1.4
Chad Foor
Greenhorn

Joined: Jul 03, 2007
Posts: 23
I'm aware of being able to reference 'helper' bean directly in my JSP by
declaring a managed-bean in my faces-config.xml.

What I want to do is reference the 'helper' bean directly from my 'inputForm' bean. Both beans are declared as managed-beans in the faces-config.xml file.

'helper' bean contains the information I need to display a datatable. (something that I'd originally declared to get something working inside the 'inputForm' bean.) But now, I want to separate that code out into its own class(bean) into 'helper' and reference that directly.

I'm using JSF 1.1 here. The books I'm looking at only hint at the ability to do a dependency injection, which is what I want here, but do not show a concrete example of how to do this.

I'm looking for a good code example of how to do this.

Appreciate any help.

Thanks,
Chad
[ November 16, 2007: Message edited by: Chad Foor ]
Chad Foor
Greenhorn

Joined: Jul 03, 2007
Posts: 23
I figured it out. What I was looking for was a ValueBinding item that allowed me to set a property in the helper class from the input form class. (Was pretty painless once I stared at the Managed Bean sections of my JSF texts.) (just didnt know what it was 'called' per se. )
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: communication between 2 session beans