Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
by Unknown user

Read Part 10

I originally chose the School.app as my test bed for applying my many-to-many checkbox classes to an ABC app. I had a browse that looked like this:

...

I previously created a persister class that can write the linking data to a TPS file, and looking at that code I can see that it contains much of the code that I'll need if I want to write to any file managed by the ABC classes. But I don't want to derive my ABC persister from that class because CML_Data_ManyToManyLinksPersisterForTPS contains an actual definition if definition of a TPS file which I won't use and which will only confuse the situation. 

...

When I first threw the checkbox code into my test app I put together a couple of routines in place of some embed code. I didn't have a really good reason for doing that (too many legacy apps on my brain lately?), and when Mike Hanson looked at the code he quickly pointed out that the code should be in local class methods.  

Here's the procedure-level class that wraps up all of the functionality: 

Code Block
CheckboxList         class
ListCheckbox            &CML_UI_ListCheckbox
Persister               &CML_Data_ManyToManyLinksPersisterForABC
Links                   &CML_Data_ManyToManyLinks
Construct               procedure
Destruct                procedure
DisplayCheckboxData     procedure
Init                    procedure
LoadEnrollmentData      procedure
SaveEnrollmentData      procedure
                    end

...

To be safe, call either MyBrowse.UpdateBuffer (which fetches the highlighted record from the queue and updated the corresponding fields in the record), or MyBrowse.UpdateViewRecord (which additionally fetches the record from the database). Alternatively Avoid low level code like GET(Queue:Browse:1,CHOICE(?Browse:1)).

Also, I often want the user's "click" to fire some code, even if the record hasn't changed. That's why I'll often use the TakeAccepted handler for the control event, rather than (or in addition to) the browse class' TakeNewSelection method.

...

I often have this experience when writing classes - although there's more work up front, there are many little paybacks (and sometimes big paybacks) later on in the process. 

Next time: A template to make it all easy.

Download the source (the checkbox classes are also available on GitHub but are not yet exported from the library).