Trying to Clarify Flags on Business and Collection Objects  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Trying to Clarify Flags on Business and Collection Objects

Postby SBarnes » Sat Feb 06, 2021 1:41 pm

When building custom Collection Item object or Business Logic object how and when do the Delete, Change and Insert flags need to be set?

I fully understand how these work in the iSave scenario.

I realize that in having properties you should call NotifyPropertyChanged and this will set the change flag and creating a new object or clearing one should turn on the insert flag but what about the Read function?

Also with a collection item it doesn't appear that it sets the flags on the collection itself, should it?

What I am trying to achieve is say you have a maintenance form that has a business login object that has a property that is a a Jiwa Collection similar to the the scenario of a sales order with lines in other words a header object and a collection of lines how to best control the save, cancel and delete buttons on the form as I want to have a SetButtons function that will be have appropriately using the Business Logic object that the form is using and looking at the flags?
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1618
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Trying to Clarify Flags on Business and Collection Objec  Topic is solved

Postby Mike.Sheen » Mon Feb 08, 2021 12:05 pm

SBarnes wrote:When building custom Collection Item object or Business Logic object how and when do the Delete, Change and Insert flags need to be set?

I fully understand how these work in the iSave scenario.

I realize that in having properties you should call NotifyPropertyChanged and this will set the change flag and creating a new object or clearing one should turn on the insert flag but what about the Read function?

Also with a collection item it doesn't appear that it sets the flags on the collection itself, should it?

What I am trying to achieve is say you have a maintenance form that has a business login object that has a property that is a a Jiwa Collection similar to the the scenario of a sales order with lines in other words a header object and a collection of lines how to best control the save, cancel and delete buttons on the form as I want to have a SetButtons function that will be have appropriately using the Business Logic object that the form is using and looking at the flags?


We handle all that for you for collections, so you should never need to set them.

The only conscious effort you need to make are 2 things, 1. - as you already stated - invoke the NotifyPropertyChanged method in property setters and that will set the ChangeFlag for you.

The Add method of the collection will set the InsertFlag - but only if the Reading flag of the collection is False (which is the 2nd thing you need to do - you should be setting the Reading flag of the collection to true inside the Read method of the collection, and then back to what it was before you set it to true in a finally of the Read method.

Remove method of the collection will set the DeleteFlag for you - but only if the InsertFlag is currently false (we don't want a save to do anything in that scenario).

If your business logic object has a property which is a JiwaCollection, then you should handle the Added, Removed and Changed events of that collection in your business logic and invoke the NotifyPropertyChanged method - that will set the ChangeFlag of the business logic. To prevent this being set when reading, do just as I instructed for the collection - in the Read method, set IsReading to true, then read your collections and set properties, and set the IsReading back to what it was in the finally of the Read method.

You should also use the Clear method of both collections and business logic inside your Read methods and CreateNew.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756

Re: Trying to Clarify Flags on Business and Collection Objec

Postby SBarnes » Mon Feb 08, 2021 12:37 pm

Thanks Mike,

What you have outlined was what I was doing, I worked out where I was coming undone, I had added a function to the collection called AddBlankLineAtEnd which added a blank line if needed to the end of the collection and was called at the start of the form's DisplayLines function so I always had an editable open line on the end of the grid as soon as I stored the change flag of the collection before it did the add and switched it back afterwards the buttons behaved i.e. the blank line wasn't considered a change.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1618
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 5 guests