Hi folks,
having the following code (in an adapter-class called “SOAMaint1”):
public void onCheck()
{
SOAMaint1 meinAdapter = (SOAMaint1) findAdapter(SOAMaint1.class,this.findSessionId());
System.err.println("*****************");
System.err.println(this.toString()+" ist meine ObjektInstanz");
System.err.println(this.getClass().getName()+" wurde gerade neu erzeugt !");
System.err.println(this.findSessionId()+" ist die verwendete SessionID");
System.err.println("********---------------*********");
System.err.println(meinAdapter.toString()+" ist die ermittelte ObjektInstanz ");
System.err.println(meinAdapter.getClass().getName()+" ist die ermittelte Klasse!");
System.err.println(meinAdapter.findSessionId()+" ist die verwendete SessionID ");
System.err.println("*****************");
}
I’ll get this output:
SOAMaint1@1631573 ist meine ObjektInstanz
SOAMaint1 wurde gerade neu erzeugt !
CASA1_1134985173706 ist die verwendete SessionID
---------------*
SOAMaint1@119db9e ist die ermittelte ObjektInstanz
SOAMaint1 ist die ermittelte Klasse!
CASA1_1134985173706 ist die verwendete SessionID
In other words: I will get for each call to findAdapter a new instance of
the wanted class !!!
Of course this piece of code is sensless, but if i call this findAdpater in another class it will behave as this.
Hi Martin,
a 1:1 translation of what you do from German to English could be: the way you shout into the forest is the way the forest shouts at you!
The second parameter of findAdapter (the one following the class) is the “adapterId”: a session is subdivided into sub-sessions (typically done by the workplace). Inside a sub-session you typically have one adapter object per adapter class - but you might also have multiple, each one separated by the “adapterid”. In all page operations (e.g. findAdapter(), switchToPage()…) you - if using the adapterid - have to clearly specify the id.
In your scenario you specify the session-id of the current adapter to be used as adapterid of the other adapter. The adapter will be created in the same session, the same sub-session, but as different adapter object (because of different adapterid).
Only use adapterid’s when you really have good reason to do it, i.e. if you want to explicitly define two adapter objects (of same class) inside one sub-session. In “normal” scenarios use findAdapter(class) instead of findAdapter(class,adapterid).
Hope, this helps…
Bjoern
Hi,
first of all: you are right but it does not help us.
The original problem was using findAdapter(*.class) from another CAI-Adapter-Class. There we get allways not the expected instance back.
Imagine the following case:
User calls via workplace a page (-> SOAMaint1.class). After using this page the user navigates through the workplace-menu to another topic
and calls again another page (-> Report1.class)
In the SOAMain1.class the following code was placed and were executed by a button-klick-event:
public int onCheck()
{
System.err.println(this.toString()+" ist die aktive ObjektInstanz “);
System.err.println(this.getClass().getName()+” ist die aktive Klasse!");
}
In the Report1.class the following code was placed:
public void init() {
SOAMaint1 meinAdapter = (SOAMaint1) findAdapter(SOAMaint1.class);
System.err.println(meinAdapter.toString()+" ist die ermittelte ObjektInstanz “);
System.err.println(meinAdapter.getClass().getName()+” ist die ermittelte Klasse!");
}
The answer on command-line was:
SOAMaint1@b83be0 ist die aktive ObjektInstanz
SOAMaint1 ist die aktive Klasse!
SOAMaint1@7787a5 ist die ermittelte ObjektInstanz
SOAMaint1 ist die ermittelte Klasse!
The problem exist as you can see. we expect to stay in the same session but if we try to obtain the automatically build adapter (SOAMain1.class) we get a complete new object … having not the values set we nedd to process … urrrgggssssss…
Hi,
after reading the fucking manual i got my error. Using the workplace leads always to a new subsession, and this means a new adapter is created …
cu martin