Modification of adapter class in a workplace scenario

Hi,

I have an Application Designer page which is targeted to be opened as a new page in the content area of a multiframe workplace. Usually it is possible to access the adapter via “…findAdapter()” and apply any values/settings to the adapter - how can I apply changes to an adapter class in a workplace scenario? The findAdapter method will always get back with a new instance of the class, as it checks the current subsession, but I need the instance created by the workplace.


CreateProgramAdapter cpa = (CreateProgramAdapter)findAdapter(CreateProgramAdapter.class); 
cpa.setMember("Some value...");

IMFWorkplace wp = (IMFWorkplace)findSessionContext().lookup(IMFWorkplace.IWORKPLACE_LOOKUP,false);
wp.addPageToWorkplace("/scMockup/createProgram.html","Title...");
wp.updateWorkplace(this);

I guess I need a method where I simply pass in a subsession ID and the method returns the adapter - in stead of using findAdapter(). Is there anything available?

Thanx in advance, Florian.

Hi Florian,

it is exactly the way you said it. There is a certain API (interface IInteractionSessionMgr) to access an adapter from another subsession…


        IInteractionSessionMgr ism = InteractionSessionMgrFactory.getInteractionSessionMgr();
        MyAdapter ma = ism.findAdapterInSubsession(findSessionId(),
                              subsessionId, 
                              "com.somewehre.MyAdapter", 
                              "", 
                              "projectname");
        // know do something here....
        ma.initData();

When you add a page to the workplace, the new page is running it is own sub session. Method “addPageToWorkplace” returns the subsession id the page is later running in…


        IMFWorkplace wp = (IMFWorkplace)findSessionContext().lookup(IMFWorkplace.IWORKPLACE_LOOKUP,false); 
        String subsessionId = wp.addPageToWorkplace("/scMockup/createProgram.html","Title..."); 

Take care that the sub session is not created so far (…creation is triggered by page load within the browser…). You can create the subsession in advance in order to get a handle to the adapter instance that later on manages the upcoming screen.

The complete code to add the page and to prepare the screen adapter looks like this…


        IMFWorkplace wp = (IMFWorkplace)findSessionContext().lookup(IMFWorkplace.IWORKPLACE_LOOKUP,false); 
        String subsessionId = wp.addPageToWorkplace("/scMockup/createProgram.html","Title..."); 
        IInteractionSessionMgr ism = InteractionSessionMgrFactory.getInteractionSessionMgr();
        ism.createNewSubsession(subsessionId);
        MyAdapter ma = ism.findAdapterInSubsession(findSessionId(),
                              subsessionId, 
                              "com.somewehre.MyAdapter", 
                              "", 
                              "projectname");
        // know do something here....
        ma.initData();
        wp.updateWorkplace(this); 

Martin

Cool! :smiley:

…that’s exactly what I dedsired, thanx Martin!

Cheers, Florian.