Ruslan Minasian
Nov 4, 2010
visibility 4265
star star star star star
(0 votes)

Custom Property Type and SaveData Method

In out project we use PropertyPageReferenceCollection to store references to local pages. It has PageReferenceCollection under the hood and calls its Parse and ToString methods to load and save the data. Evetything was fine until we decided to make some property (let’s call it Links) of this type required. The application started to crash while loading the page with empty Links property.

I’ve spend a lot of time looking how to prevent LoadData from crash while the error was in SaveData method. When LocalPageProvider loads a page it goes through all the properties from DB calls PropertyData.LoadData method for each property which value is not DBNull.Value. Since our SaveData implementation used PageReferenceCollection.ToString it returned string.Empty for empty collection and that value was stored in the DB. Then, after we set Links property as required, LoadData started to crash since string.Empty caused PropertyData.Clear to be called for required property.

Moral: always implement SaveData property so it returns null if PropertyData.IsNull is true.

Nov 04, 2010

Comments

error Please login to comment.
Latest blogs
From Review to Release: Publishing My First Optimizely OCP App

Building an OCP app is only half the story. This post follows Publish Child Items from its first submission to a live App Directory release: what...

Chirag Khanna | Nov 16, 2026 |

Brilliant and Ignorant: Building an Optimizely Knowledge Base for AI Agents

Claude is a brilliant developer who has never seen Optimizely. How we gave our agents the framework experience a human needs half a year to earn:...

Allan Thraen | Nov 16, 2026 |

Budgeting for Agent Platform credits in 2027

How to budget for Optimizely Agent Platform (formerly Opal) credits in 2027: what a credit buys, how to size use cases, and what to agree with...

Matthew Dunn | Nov 15, 2026 |

Integrating Siteimprove with Optimizely: From Accessibility Compliance to Content Excellence

Over the last few months, I’ve worked on several Optimizely solution designs involving accessibility, SEO, analytics, governance, and content...

Madhu | Nov 14, 2026 |

Fallback images that fit: handling broken images with a service worker

A broken image is never the right shape On a content-heavy commerce site, some images will fail. Editors delete assets that are still referenced, C...

Allyn Thomas | Nov 14, 2026

First Impressions of Optimizely Mark Desktop

What is Mark Desktop Optimizely have announced the release of the Mark Desktop App. Mark is the name for the Optimizely Agent Platform formerly kno...

Mark Stott | Nov 12, 2026