how to call a form from parent scheme

For questions and postings not covered by the other forums
mario
Posts: 11
Joined: Fri Sep 04, 2009 11:02 am

how to call a form from parent scheme

Postby mario » Fri Oct 30, 2009 12:36 pm

I have a program called InvoiceControlSchema

Root
-->InvoiceControlModalSchema
----->InvoiceControlViewSchema

I have created a form (frmMyControls) under ModalSchema and I have another form under ViewSchema

I would like to call frmMyControls from a button inside my form in ViewSchema.

How can I do this? Is it possible to call a form from one level below?

Cheers, Mario :)

allistar
Posts: 156
Joined: Fri Aug 14, 2009 11:02 am
Location: Mount Maunganui, Tauranga

Re: how to call a form from parent scheme

Postby allistar » Fri Oct 30, 2009 12:39 pm

Yes, just create an instance of the form class and do a .show (or .showModal) on it from the ViewSchema.

mario
Posts: 11
Joined: Fri Sep 04, 2009 11:02 am

Re: how to call a form from parent scheme

Postby mario » Fri Oct 30, 2009 12:45 pm

thanks mate, i am a bit new to programming...
how do you create an instance of a form class in jade?
cheers :)

User avatar
BeeJay
Posts: 312
Joined: Tue Jun 30, 2009 2:42 pm
Location: Christchurch, NZ

Re: how to call a form from parent scheme

Postby BeeJay » Fri Oct 30, 2009 12:55 pm

The code to show a form defined in your InvoiceControlModelSchema is exactly the same as the code to show a form defined in your InvoiceControlViewSchema.

Code: Select all

btnDoIt_click( btn : Button input ) updating; vars f : FrmMyControls ; begin create f transient ; f.show(); end;
Having said that, I'd question why you are defining any forms in your InvoiceControlModelSchema anyway, as that kind of negates the point of having the Model/View separation you've created in your schema hierarchy?

Cheers,
BeeJay.

mario
Posts: 11
Joined: Fri Sep 04, 2009 11:02 am

Re: how to call a form from parent scheme

Postby mario » Fri Oct 30, 2009 12:59 pm

i did it...didnt used your approach though...but thanks :)

i clicked F4 in my viewSchema and added the form (which is defined in ModalSchema.

and then i was able to call the form per normal.

Cheers and thanks :)

User avatar
BeeJay
Posts: 312
Joined: Tue Jun 30, 2009 2:42 pm
Location: Christchurch, NZ

Re: how to call a form from parent scheme

Postby BeeJay » Fri Oct 30, 2009 1:03 pm

Pressing F4 to find the form will only have added it to the class list for that session of the CHB unless you've created a subschema copy by adding an additional method or by subclassing the form. Either way you could still have created the form for runtime use in your app using code similar to the above.

I'd still restate why are you defining any forms in your Model schema anyway?

Cheers,
BeeJay.

mario
Posts: 11
Joined: Fri Sep 04, 2009 11:02 am

Re: how to call a form from parent scheme

Postby mario » Fri Oct 30, 2009 1:11 pm

thanks pal :)
well i didnt want to create a form in ModalSchema.

I got all my forms in View Schema.

but there is one form I created using the wizard and I like the way it is created, but unfortunately it creates itself everytime under ModalSchema. I am unable to move it to ViewSchema.

So I thought if there is a workaround....

now that you have asked, do you have any idea if I can move the form from Modal to View Schema?
cheers, Mario :)

User avatar
BeeJay
Posts: 312
Joined: Tue Jun 30, 2009 2:42 pm
Location: Christchurch, NZ

Re: how to call a form from parent scheme

Postby BeeJay » Fri Oct 30, 2009 1:39 pm

You could try the following, I haven't tested this so I can't confirm if it will work or not:

1. Do an extract of your form from your "ModelSchema" - select the form in your class browser, right click and choose the extract option.
2. Remove the form from your "ModelSchema".
3. Swap context to your view schema and do a schema load, selecting the .cls and .ddb files that were created at step 1 for the "Schema File Name" and "Forms File Name" fields respectively, but don't click OK yet.
4. Click the "Advanced" button.
5. Select your "ViewSchema" in the "Target Schema" field.
6. Click ok to save the Advanced options.
7. Click ok to start the schema load.

If all goes well, you should now find the form is in your "ViewSchema".

Cheers,
BeeJay.

mario
Posts: 11
Joined: Fri Sep 04, 2009 11:02 am

Re: how to call a form from parent scheme

Postby mario » Fri Oct 30, 2009 1:58 pm

dude ...that's awesome :) it totally worked :D
you must be good with jade.....i thought no one uses jade around here....


not to taking too much advantage of your skills, but do you know how I can create a search function in jade?

I got a simple example, where i can add few users users. I can save/edit/delete them... but i am a bit stuck in creating a search for it, I will give it a depthought tonight but any hints will be awesome?

cheers, mario :)

User avatar
BeeJay
Posts: 312
Joined: Tue Jun 30, 2009 2:42 pm
Location: Christchurch, NZ

Re: how to call a form from parent scheme

Postby BeeJay » Fri Oct 30, 2009 2:34 pm

Searching support is often a whole module in its own right, with a number of systems implementing their own keywording algorithms and "keywording objects" to prebuild all the "keywords" for a given object into some form of keyword/search manager. Without going to this extent of development, you do have some rather crude options available that while they will "work" are not options that would scale well for large data volumes.

1. The simplest approach would be to take a "filter string" and simply do a String::pos call on the appropriate string properties to see if they're a match.

2. Another approach, assuming you're supporting searching only over a single field such as surname could be to have a dictionary of people keyed by surname, then use an iterator and startKeyGeq to quickly get to the first "match", and then continue iterating until the name is no longer a match. This won't work if you need to support finding a match part way through a surname but will be faster for a search for say john* to find all the johns, johnsons, johnstons, and johnstones in your system.

As I said at the beginning, neither of these options is particularly elegant, and I'm certainly not recommending them as good options in a real world commercial application as they have obvious limitations, but they may work for your requirements.

If you're happy to invest the time, and it's not going to be an over-engineering of your project requirements, then to support better searching you'll need to look at creating a search manager with a collection of keywords, with each keyword having a collection of the objects that "contain" that keyword. Then you can write some much better performing search code to get all the keywords that match a given search criteria, then combine all the objects for each of those keywords into your final result set. You do, however, have to have some way of "keywording" the objects as you create/update them. For reasons of contention and performance, a lot of systems will engineer a lazy update pattern to do this keywording via a background process. This means that the actual updating of those objects doesn't also have to do the keywording, which could have a dramatic negative impact on the overall transaction time, and means you only have a single updater process affecting the keyword manager and keyword objects.

Cheers,
BeeJay.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 3 guests