# How to destroy the life cycle of an Application Designer adapter from a Natural program?

**URL:** <https://techcommunity.softwareag.com/t/how-to-destroy-the-life-cycle-of-an-application-designer-adapter-from-a-natural-program/170735>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, NaturalONE, Natural-for-AJAX\
**Created:** [April 18, 2013, 3:59pm UTC](https://techcommunity.softwareag.com/t/how-to-destroy-the-life-cycle-of-an-application-designer-adapter-from-a-natural-program/170735 "2013-04-18T15:59:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Orlando\_Bissacot\_Neto1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/orlando_bissacot_neto1/32/342_2.png) [@Orlando\_Bissacot\_Neto1](https://techcommunity.softwareag.com/u/Orlando_Bissacot_Neto1)\
**Post date:** [April 18, 2013, 3:59pm UTC](https://techcommunity.softwareag.com/t/how-to-destroy-the-life-cycle-of-an-application-designer-adapter-from-a-natural-program/170735/1 "2013-04-18T15:59:34Z")

</div>

At the “Application Designer” documentation overview:  
• Chapters: Special Development Topics → Details on Session Management → How Things End  
• Topic: “End of an Application Designer Adapter”

We can see that:  
Adapters typically stay alive until the subsession ends in which they are living. There is also an API available to directly end adapters:  
• Method Adapter.markThisAdapterForDestroy().  
• Via the interface IInteractionProcess which you receive inside an adapter via this.m\_interactionProcess.

Question:  
• Is it possible to destroy the life cycle of an Application Designer adapter from a Natural program?

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 18, 2013, 7:01pm UTC](https://techcommunity.softwareag.com/t/how-to-destroy-the-life-cycle-of-an-application-designer-adapter-from-a-natural-program/170735/2 "2013-04-18T19:01:09Z")

</div>

Questions:

1.) Why would you need to do this ?

2.) Are you really talking about an Application Designer Adapter or a Natural Adapter ?

---

<div class="post-metadata">

**Author:** ![Orlando\_Bissacot\_Neto1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/orlando_bissacot_neto1/32/342_2.png) [@Orlando\_Bissacot\_Neto1](https://techcommunity.softwareag.com/u/Orlando_Bissacot_Neto1)\
**Post date:** [April 18, 2013, 8:00pm UTC](https://techcommunity.softwareag.com/t/how-to-destroy-the-life-cycle-of-an-application-designer-adapter-from-a-natural-program/170735/3 "2013-04-18T20:00:37Z")

</div>

Hi Wolfgang,

First of all, let me thank you for your attention and answer your questions…

i Why would you need to do this ?[/i]  
Answer: I need to exchange context data in an Application Server environment (in a Natural for AJAX workplace corporate portal) between: [1] a Natural for AJAX page and [2] a Natural map in a 3270 terminal emulation into this portal.

i Are you really talking about an Application Designer Adapter or a Natural Adapter ?[/i]  
Answer: I’m talking about a Natural Adapter which seems to stay alive until the subsession ends in which they are living, in a way similar as occurs with Application Designer adapters.

I can keep this context data exchanging working as intended with one exception: I always can “put” the context data from the Natural program (3270), but I just can “get” the context data to the Natural program 3270 only at the first time my program interacts with the context information and I think it is happening because the life cycle of the adapter instance…

You can see listed below an example of the Natural 3270 program and the Natural for AJAX page this program is calling…

NATURAL 3270 PROGRAM:  
[size=9]DEFINE DATA LOCAL  
/\* [ADAPTER] Adapter variables  
1 CONTEXT  
2 PARM (A) DYNAMIC  
1 XCITRIGGEREVENT (A) DYNAMIC  
/\* [MAP] 3270 interface variables  
1 #MAP  
2 #FIELD1 (A30)  
2 #FIELD2 (A30)  
2 #MESSAGE (A70)  
END-DEFINE

- [KEY] PF-KEYS assignment  
FORMAT KD=ON  
SET KEY PF3 NAMED ‘Quit’  
SET KEY PF10 NAMED ‘C-\>M’  
SET KEY PF11 NAMED ‘M-\>C’
- [3270] User interface  
REPEAT  
INPUT WITH TEXT #MESSAGE  
‘C O N T E X T T E S T’ ///  
‘Context parameter:’ #FIELD1 (AD=MILT’_‘) /  
‘Map parameter…:’ #FIELD2 (AD=MILT’_')  
DECIDE ON FIRST VALUE OF _PF-KEY  
VALUE ‘PF3’  
ESCAPE MODULE  
VALUE ‘PF10’  
/_ [AJAX] Interacts with Natural for AJAX page to get the context information  
MOVE ‘nat:page.end’ TO XCITRIGGEREVENT  
PROCESS PAGE USING “EXPAGE1”  
/\* [3270] Move the context information to the 3270 map  
MOVE CONTEXT.PARM TO #MAP.#FIELD1  
RESET #MAP.#FIELD2  
/\* [MSG] Set the message  
MOVE ‘Moved: from CONTEXT to MAP’ TO #MAP.#MESSAGE  
VALUE ‘PF11’  
/\* [3270] Move the 3270 map information to the context  
MOVE #MAP.#FIELD2 TO CONTEXT.PARM  
/\* [AJAX] Interacts with Natural for AJAX page to put the context information  
MOVE ‘nat:page.end’ TO XCITRIGGEREVENT  
PROCESS PAGE USING “EXPAGE1”  
/\* [MSG] Set the message  
MOVE ‘Moved: from MAP to CONTEXT’ TO #MAP.#MESSAGE  
/\* [3270] Adjusts the context information at the map  
MOVE CONTEXT.PARM TO #MAP.#FIELD1  
NONE  
MOVE ‘Invalid key’ TO #MAP.#MESSAGE  
END-DECIDE  
END-REPEAT
- 

END[/size]

NATURAL FOR AJAX PAGE  
\<?xml version="1.0" encoding="UTF-8"?\>  
   
 njx:triggerevent  
\</njx:triggerevent\>

Best regards,  
Orlando.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 18, 2013, 8:17pm UTC](https://techcommunity.softwareag.com/t/how-to-destroy-the-life-cycle-of-an-application-designer-adapter-from-a-natural-program/170735/4 "2013-04-18T20:17:01Z")

</div>

Ok, so this question and the other one from Euler Nieto are actually the same issue, right ?

I’m still greatly confused about how 3270 comes into play here - when you are talking about 3270 and subsessions, are you talking about WebIO running as one session within your portal, or as a subpage within a page within your portal ?

---

<div class="post-metadata">

**Author:** ![Orlando\_Bissacot\_Neto1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/orlando_bissacot_neto1/32/342_2.png) [@Orlando\_Bissacot\_Neto1](https://techcommunity.softwareag.com/u/Orlando_Bissacot_Neto1)\
**Post date:** [April 18, 2013, 9:18pm UTC](https://techcommunity.softwareag.com/t/how-to-destroy-the-life-cycle-of-an-application-designer-adapter-from-a-natural-program/170735/5 "2013-04-18T21:18:36Z")

</div>

You can consider that Euler is working with me in this issue, but our questions are not exactly the same.

Let me try to explain the relation between 3270 and subsessions. The whole problem is about context data, which can be implemented with the “xcicontext” and “xcicontextparameter” controls in an application designer Natpages…

Our corporate portal have an architecture similar as that used at the Application Designer workplace and was implemented from the workplace examples we can see at the “njxdemos” project. This portal have a lot of menu options, mostly pointing to Natural for AJAX applications, but some to Natural CUI (character user interface) programs. We need to exchange context data between these different applications.

Therefore, the challenge is to exchange this “context data” between different subsessions of Natural for AJAX pages (which is working fine) and some subsessions of Natural 3270 terminal emulations we can have running in parallel under the same session of this portal.

These emulations are using the “natlegacy” page from the “cisnatural” project at the Application Designer. So, I’m talking about Natural for AJAX sessions (started with StartCISPage) which deals with CUI objects: programs with Natural maps displayed with the INPUT [USING MAP ‘MAP\_NAME’] statement, but started with the StartCISPage servlet.

As you can see at the Natural program attached above, we included, in this CUI program, two pf-keys:  
PF10 – Which we use to “get” the session’s context area.  
PF11 – Which we use to “put” the program’s local data to the context area.

We can implement these facilities with a “dummy” page (which was attached above as well): we just have to start it as a “blink” (a triggerevent + a PROCESS PAGE statement) to interact with the portal’s current context area. It is working: always to the “put” operation; but only for the first time, to the “get” operation.

I think the problem is occurring because the “get” operation only works with brand new adapter instances. This is the reason of my question: I want to destroy the adapter instance after the “blink” triggered with the PF10 key.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:28pm UTC](https://techcommunity.softwareag.com/t/how-to-destroy-the-life-cycle-of-an-application-designer-adapter-from-a-natural-program/170735/6 "2021-04-02T15:28:38Z")

</div>


