* * *

Author Topic: tiOPF questions  (Read 793 times)

Wargan

  • New member
  • *
  • Posts: 48
    • 'This way' site
tiOPF questions
« on: February 05, 2018, 09:48:34 am »
Hello, friends.

I've been programming in Lazarus for several months and recently discovered the tiOPF framework [http://tiopf.sourceforge.net]. As it turned out, this is a difficult job. On the Internet, there is very little documentation and step-by-step examples.

It's very difficult for me to study this framework, so I decided to create this topic so that people can also learn this.

I have a few questions that I will ask here:

First
I downloaded tiOPF v2.5.x by saving the repository snapshot from Sourceforge. Then, after studying, I created a TStreet class containing only one property - Name. Next, I created a container for TStreet, calling it TStreetsList, inheriting it from TTiObjectList. I set up the creation, deletion, updating and reading from the database with the help of visitors, as it was written in the examples.

But there is a problem. If you add objects to TStreetsList, they are of course automatically saved in the database (this is correct). But by changing objects, they are not saved!

I had to do fStreet.ObjectState := posEmpty before saving, and it's messy. How can I make it work properly? Also I checked the OneToMany example and as it turned out, it also does not save changes (except for adding) to the database automatically.

Second
I'm very interested in working with mediators for TComboBox. How to bind an enumerated type to it?

Third
Also about the mediator for TVirtualStringTree. There is one working sample in the <tiopf>/Quarantine/ folder, but there is absolutely no documentation for it.
Lazarus 1.8RC5+ FPC 3.0.4.
Windows 7 x32, RAM 3 Gb.

Wargan

  • New member
  • *
  • Posts: 48
    • 'This way' site
Re: tiOPF questions
« Reply #1 on: February 08, 2018, 07:01:34 am »
So, I was able to independently find the answers to two questions, it is possible that someone will come in handy.

First. In order to save a single object before saving, you must make the Dirty property true.

Code: Pascal  [Select]
  1. fStreet.Dirty: = true; // step # 1
  2. fStreet.Save; // step # 2

Second.
To attach to the combo box of the addressable type, you need to do this:

Code: Pascal  [Select]
  1. type TGender = (Male, Female);
...
eGenders is the Subject property to which the mediator is attached.
...

Code: Pascal  [Select]
  1. fMediator.AddProperty ('Gender', cmbGender) .ValueList: = eGenders;

Mediator is TTiModelMediator;
Lazarus 1.8RC5+ FPC 3.0.4.
Windows 7 x32, RAM 3 Gb.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus