cancel
Showing results for 
Search instead for 
Did you mean: 

Factory method problem using two models

Former Member
0 Kudos
460

I'm currently developing an application using two controllers and two models and I'm running into problems which I think are being caused by the WDModelFactory class.

The first controller and (RFC) model I made are used for retrieving a set of customers from an R/3 system. I've made a view that uses a table control to present all the customers on screen. This works fine. I also have a button on this screen that triggers an outbound plug of the view. This outbound plug is connected to an inbound plug of the view that should present the details of the selected customer. When I fire the outbound plug an exception occurs which seems to be caused by a statement in the wdDoInit method of the second controller. I've determined that the error is caused by a call to the WDModelFactory class.

When I execute the statement "DetailsModel = (Mdl_Details)WDModelFactory.getModelInstance( Mdl_Details.class, WDModelScopeType.APPLICATION_SCOPE);" I get a ClassCastException error. In the error information I can see that the error occurs not in the CustomerDetails model but in the CustomerList model! It seems to me that the factory method is in fact not returning an instance of a CustomerDetails model but an instance of a CustomerList model. I think this is a problem in the WDModelFactory class.

Has anybody else had this problem, or is it just me?

We are using beta II

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Bertil,

Could you please check if the model in each controller is specified correctly?

An alternative would be to create a single model that contains the RFC proxies for both BAPI's. Then you would only need to create a single model object. Once this is done, a reference to the model object should be stored in the context of the component controller. The reference to this model can then be picked up by any view controller that uses the component controller. Thus, models are created at component controller initialisation time, and used on an "as needed" basis by the view controllers.

Hope that helps!

Karin