I need to access the method of another bean and this method should use data from the calling bean.
Is this possible without creating a new instance of that method-bean?
Because im building a universal database-searchengine configured by xml and also the commandbuttons
are defined there. And i dont want that the guy who is using this engine has to change or add programm code!
I have you know we're all respectable professional professionals here. Just look at how dignified our Moose is!
JSF is based on the Inversion of Control concept. In IoC, the way for one bean to reference another bean is that the framework injects the referenced bean into the referencing bean using its POJO "set" method plus wiring rules which originally came from faces-config.xml but can (as of JSF2) also be constructed from @ManagedBean/@ManagedProperty annotations..
It sounds like you have a use case I've worked with a time or 2 myself. I present a search form, the user enters search criteria, hits the "search" button and results come back. Here's how I do it:
First, I have a backing bean for the search form. This is a short-lived bean and is one of the few cases in JSF where you can get away with using Request Scope.
The primary bean that will actually fire off the search and manage the search results is typically a session scope bean that has been wired into (injected) into the search form backing bean.
The action method of the search bean collects the search parameters, which are properties of the search bean and thus have been set by JSF when you clicked the "search" button. It can then invoke a search method on the search bean that was injected into the search form bean. It's up to the designer whether to inject the search properties as properties to the search bean or simply pass them as arguments to the search function (or mix-and-match, for that matter).
Once the search form's action processor has done its thing, it returns a navigation indicator that would either present the results of the search or some type of error page. Unless it would rather go somewhere else, instead.
Customer surveys are for companies who didn't pay proper attention to begin with.