smartwindow launch from external procedure.

Posted by steven.post on 09-Dec-2008 03:28

Hi guys,

when I set up smart window(containing a toolbar, sdo, dyn. browse, dataviewer, filter and tabfolder), and then I put a procedure in the main block, the procedure runs as expected.

However when I call this smart window from an external .w (a regular window, using a UI trigger on a button to say "RUN smartwindowname.w.") the added procedure doesn't execute until you click the close button of the smart window (the 'x' in the upper right corner), while it should be running right before the user gets control over the window.

The main block contains the following code

/* ***************** Main Block ************* */

/* Include custom Main Block code for SmartWindows. */

/* some include file added by the appbuilder, including the comment line above */

RUN checkACL. /* <<-- internal procedure I added myself */

I'm running OE10.1c studio

PS: Why is it always me who gets this weird behaviour?

All Replies

Posted by Admin on 09-Dec-2008 03:40

If you check the windowmn.i, you'll see that it contains

IF NOT THIS-PROCEDURE:PERSISTENT THEN

WAIT-FOR CLOSE OF THIS-PROCEDURE

Your RUN smartwindowname.w. is NOT persistent. That's why the WAIT-FOR prevents the execution of the RUN checkACL. until the user closes the window.

Your first smartwindow must be run persistent - either from the AppBuilder or a menu system.

Two thoughts:

1.) I usually launch smart windows persistently:

RUN smartwindowname.w PERSISTENT SET hnewsmartwindow.

RUN initializeObject IN hnewsmartwindow.

2.) Try to avoid too much code in the main-block of any smart object. Before the windowmn.i might work, but definitively not behind (as you noticed).

The ADM2 offers hooks for almost everything. To work on the startup process of any smartobject, a local override of the procedure initializeObject is usually a better place, or something like postCreateObjects (hope that name is 100% correct).

Posted by steven.post on 09-Dec-2008 03:56

Why didn't I think of that? Thanks, the Initialize object does it right when I put the code behinde the 'RUN SUPER' statement.

I couldn't find that postCreateObjects procedure you mentioned though, nor anything that looked like it.

Putting my statement before the include is no solution, as it accesses the toolbar, which isn't yet instantiated at that point.

Edit: this is why I don't like include files...

Message was edited by: Steven

Steven Post

Posted by Admin on 09-Dec-2008 11:02

The name is postCreateObjects .

It's not a SUPER override, so you need to create it manually. The purpose is to add code right after the instantiation of the objects on the smartwindow but before their initialization. So it's executed right in the middle of initializeObject of the window.

It's usually the place to add custom links, modify instance properties, etc...

Posted by steven.post on 10-Dec-2008 03:22

ok, I tested it with the postCreateObjects procedure, it works, but I notice that it is being called multiple times (one for each object on my smartwindow I assume?), which I don't think is really suitable here, especially with no clear way to know what is triggering it, or what is going to happen. To me, ABL is still a strange language (coming from Java).

Posted by Admin on 10-Dec-2008 03:27

It's triggered for every page that get's initialized.

You'll probably have objects on page 0 (always visible) and page 1. Objects on page 2 are only created when the user selects page 2 in the tab folder.

DEFINE VARIABLE iPage AS INTEGER NO-UNDO .

.

should tell you the page number. So if you need to apply your ACL to objects on page 2, this IS probably the best place.

Posted by steven.post on 10-Dec-2008 03:40

I need different actions on several occasions, currently I only modify a dynamic toolbar on page 0, but later on, things will go to other pages as well.

I see 3 runs of that procedure before the frame is shown, that would be page 0 and page 1 I assume, since I told it to go to page 1 on start (procedure settings...). Don't know about the third..

As soon as I click to open the second tab, it runs again, for page 2 then I assume, it doesn't run when clicking the third thab (page 3?) though.

For clarification, page 0 contains a dyn toolbar and a smartfolder, the first tab has a dynamic smartdatabrowser, the second a smartdataviewer and the third a filter

Edit: In order of execution, with the get pagenumber

- 3

- 0

- 1

- 2

Seem a strange order to me....

Message was edited by:

Steven Post

Posted by Håvard Danielsen on 10-Dec-2008 10:32

Page 3 is probably created because it has a filter-source to the SDO on page 0. I might be wrong about the actual cause, but the page creation order you see is very likely as expected.

There's logic to also initialize pages that the initial pages depend on. The dependency is detected through the links. Basically any link SOURCE on a separate page will trigger a create of that page also. The update link is opposite, in that a page with an update-target needs to be created when the update-source page is created.

You can check for state/context in postCreateObjects as follows:

- CurrentPage (as already mentioned)

- check for valid-handle of the involved objects.

- check the ObjectsCreated property - this is set to true on the first call that creates page 0 (and init pages and "source-linked" pages), but after the first call to postCreateObjects.

- There's also a PendingPage property, which holds the target page during the page change, but I do not remember the exact sequence of this and I do not really think you should need to use this.

Posted by steven.post on 11-Dec-2008 05:03

I think I get it, so page 2 with the view isn't instantiated at that point becuase the view is an observer to the sdo, whilest the sdo is actually an observer to the filter, so it knows what query to use. (so to make the analogy with observer/observable) Correct me if I'm wrong.

It's a lot more clear now, thanks.

I never thought ABL would be so difficult when I started using it, lots of obscurities as it seems.

Posted by Håvard Danielsen on 11-Dec-2008 13:24

> I think I get it, so page 2 with the view isn't instantiated at that point becuase the view is an observer to the sdo, whilest the sdo is actually an observer to the filter, so it knows what query to use. (so to make the analogy with observer/observable) Correct me if I'm wrong.

I think your observation is correct. The adm2 link mechanism is going a bit further as it is bi-directional, but most links can have multiple targets and one source and most of the messages are from source to target. The linking is implemented with the ABL's publish/subscribe, which I guess also can be compared to the observer pattern.

> It's a lot more clear now, thanks. I never thought ABL would be so difficult when I started using it, lots of obscurities as it seems.

You cannot really draw this conclusion about ABL, the language, from your experience with ADM2, the framework implemented in ABL. On the other hand one can argue that the ABL language’s lack of interfaces and access modifiers at the time ADM2 was developed is one of the reasons that it appears somewhat obscure. Another reason the ADM2 might appear obscure is simply that it is very comprehensive… (maybe not a good excuse, but still a redeeming factor)

Note that the ABL language is now very well suited for component framework development, since it now is OO and supports .NET.

Posted by steven.post on 12-Dec-2008 02:04

Well as for obscurities, I probably would never have found that 'postCreateObjects' procedure... very well hidden to me. And seeing a framework that puts an include file somwhere, without me knowing what it even remotely does is certainly not making things easier.

The OO features as I currently use them are inadequate for me, static methods and local variables(not datamembers, but defined inside the static method) tend to give errors (compiler thinks it's an instance variable).

I have yet to try 10.2 and OEA but from what I see it is much improved since 10.1c, the one I'm currently using.

I do think ABL has some strange things going on, and as a java developer (did some .NET in the past as well), it's really different, a bit like going back in time as it seems to me :P but that's just me talking.

This thread is closed