cancel
Showing results for 
Search instead for 
Did you mean: 

Interfaces to Generated Classes

Former Member
0 Kudos

Hi

I have a web dynpro project that needs to connect to two models, each having a different jco.

What I want to do is to decide, at run time what jco to use.

I addition I do not want to multiple the same code, but only change the reference to the Jco.

So my question is : is it possible to use interface to the generated classes so that:

MyIntrerface m = new MyGeneratedClass();

wdContext.nodeMyGeneratedClass().bind(m);

m.doSomething();

because if you have two jco's their package is different and you cannot use:

if(condition_1)

{

package_1. MyGeneratedClass m = new package_1.MyGeneratedClass();

wdContext.nodeMyGeneratedClass().bind(m);

}

if(condition_2)

{

package_2. MyGeneratedClass m = new package_2.MyGeneratedClass();

wdContext.nodeMyGeneratedClass().bind(m);

}

m.doSomthing();

I hope I have made myself clear because it is rather difficult to explain.

kind regards

Yuval

Edited by: yuval peery on Aug 5, 2011 11:43 AM

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

you can create same number of DC components as number of models and connections to them.

each DC has own usual binding to model.

than you can connect your working "root" component to nedeed DC component at runtime,

depending from condition,

contexts also will be connected according interface that you will use for component creation.

so you will connect your componnt to needed model throught middle dynamically created component .

process in short:

you can create "used component" references to them

and

than you can use IWDComponentUsage for dynamic create one of thais components by its text name

depending from any condition using code like this

IWDComponentUsage usage = wdThis.wdGetITaskInterfaceDefinitionComponentUsage(); 
 
if( YOUR CONDITION 1 )
if (!usage.hasActiveComponent()){ 
	try{   
		usage.createComponent("com.sap.sdn.Task");
	}catch(WDRuntimeException e){
		//handle exception
	}
}
//next  if for nxt component name

as here:

full process as sample described more in detail here:

http://wiki.sdn.sap.com/wiki/display/WDJava/UsecomponentsinbiggerWebDynproprojects+%28componentization%29

for understanding good to begin read from

3.2 Share the same context within multiple components

3.2.1 Connecting the data component with the other components

and so on..

advanced sampl is here:

also you can connect View from creted component to ViewContainerUIElement to show UI interface

Former Member
0 Kudos

Hi Vladimir

Thank you very much for your reply

and very interesting reply this is.

I think we can use this code .

regards

yuval