Disabling Form Events

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Disabling Form Events

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:13 pm

by torrie >> Wed, 4 Sep 2002 13:27:36 GMT

I want to disable the form load event (to make generating a jfm file easier). I have tried using the enableEvent method but this seems to have no effect on the load event. (Is this a bug?) I have also tried to use the setEventMapping method to assign a new event method to the load event but this does not replace an existing method. (Is this also a bug?)

Does anyone else have any ideas.

Thanks

Torrie

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Disabling Form Events

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:13 pm

by cdshearer >> Wed, 4 Sep 2002 20:00:50 GMT

Hi Torrie

I have no idea whether it is possible to disable the form load event, but it seems you might be doing something similar to something I'm doing here.

I'm assuming you want to be able to create forms in some special mode where you don't want code in the form's load event to execute.

My solution is to do the following:

load()
begin

if not app.isInSomeSpecialMode then
formLoad();
endif;
end;


So, basically, you don't have any code in the actual load event, but instead call a form method on your top superclass form (you do have a form class hierarchy don't you?). All subclass forms put any form "load" code into a formLoad method instead of directly in the load event. That way, you can easily put a check in, as above, to prevent code from executing in special situations.

Hope this helps,

Craig

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Disabling Form Events

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:13 pm

by allistar >> Wed, 4 Sep 2002 23:21:15 GMT

What is the danger of having the load method called? Is it that it may raise an exception because some references have not been correctly initialised?

You could just arm an exception handler before hand and handle any exception that happens, althought I am not sure at what point the .jfm file gets populated with the form build data - before calling load or after? If it is before then you have a solution, if after then this suggestion won't work.

Another suggestion is to do a full schema extract of your schema,
write a jadescript that reads through the .scm file and every "load" method you find add in a "return;" just after the "begin". Then import that schema in a do you form loads. I'm not sure if the form build
data in the .jfm file is based on form class name or some other identifier which may be different using the above approach.

Allistar.

------------------------------------------------------------------
Allistar Melville
Software Developer
Auckland, NEW ZEALAND

Greentree International,
Developer of Greentree Financial Software. ------------------------------------------------------------------

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Disabling Form Events

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:13 pm

by torrie >> Thu, 5 Sep 2002 8:45:50 GMT

The main problem is with the queryUnload event, rather than the load event. This means that after the script has run I am left with a lot of forms that refuse to close because the other methods normally used to initialise the forms have not been run. The only way to

As Craig suggested I could use a flag somewhere to put the forms in a special mode and with the form hierarchy not run the event code. One problem is that some of the forms that give me problems are in schemas supplied be 3rd parties so the special mode won't apply to those forms.

I guess the extract method would work but would I have to also modify the DDB file to remove the event mapping? Sounds like a lot of work!

Torrie

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Disabling Form Events

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:13 pm

by allistar >> Thu, 5 Sep 2002 21:08:13 GMT

Torrie,
you wouldn't have to modify the ddb as all you are doing in the .scm extract is telling the load event (or in this case the quertUnload
event) to do nothing (by inserting a "return;" just after the "begin". The script to modify the .scm file wouldn't be too complicated, you
are just looking for certain tokens in the file such as:

__method
queryUnload(...);

Someone from JSC will need to comment on whether this method will
allow the .jfm file to be populated accordingly.

Allistar.

------------------------------------------------------------------
Allistar Melville
Software Developer
Auckland, NEW ZEALAND

Greentree International,
Developer of Greentree Financial Software. ------------------------------------------------------------------

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Disabling Form Events

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:13 pm

by skipton >> Thu, 5 Sep 2002 21:24:23 GMT

Greetings all from the land of the long grey cloud!

Both of the above solutions are great ideas but if there is source which you dont have control over I suppose you are left with having to alter the schema file. It does sound like a bit of work; the initial coding + undertaking the process each time you upgrade your forms (as you'll need a spare environment to load into).

I wasnt aware an event mapping was in the ddb, but If you simply replace the event methods with the default code eg.

begin
inheritMethod();
end;

instead of deleting them then you shouldnt need to touch the ddb anyway.

Wouldn't it be a neat little feature of Jade to be able to package a jfm file given input parameters of a schema name or a mul file equivalent ready for distribution?

John
JBS(UK)


Return to “General Discussion”

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 23 guests

cron