Views: 9540
Number of votes: 1
Average rating:

Itera.Objects, a extension for PageTypeBuilder

I have been looking and PageTypeBuilder, and the concept is great. But one thing I missed was the ability to add objects of all types and not only primitives or propertydata types.

I started by downloading the latest build, and looked around. The Interceptor get’s the value of a property and set’s it on the page object. I therefore had to create a property that was a wrapper around a object.  Before I have used Itera.MultiProperty to store many variables. This time I tried to use the dynamic data store, but after a couple of hours trying to set a setting on a property from code I switch over to saving them as real properties on the page.

These properties are disabled from edit mode, and I have a container property that shows these hidden properties.

image

When Page type builder finds this stuff It will create a 2 properties. But since PTB doesn’t follow type’s I have made a IInitializableModule that follows these types, and adds the hidden properties.

image

 

The property PropertyContainer will in a context of a strong Types page create the an instance of the object and populate all the primitives from the hidden property data. If it encounter another PropertyContainer it will create that object and populate it form it’s hidden properties.

image

There is actually 5 different properties, that will display a bit differently in edit mode.

  1. PropertyContainer
  2. PropertyContainerWithHelp
  3. PropertyContainerSmall
  4. PropertyContainerSmallNoBox
  5. PropertyContainerSmallWithHelp

If you specify different tab’s for the different properties the layout will also change.

image

will display in edit mode like this:

image 

and

image

How cool is that :)

And even better, the tabs have access rights!

Code is available here

Jun 17, 2010

johan.petersson
(By johan.petersson, 9/21/2010 12:33:25 PM)

Very cool!

Erik Nordin Wahlberg
(By Erik Nordin Wahlberg, 9/21/2010 12:33:25 PM)

Wow, this is really cool! To bad you did't find a way for using settings for properties via code. Have you talked with EPiServer about it?

Guest
(By Guest, 9/21/2010 12:33:25 PM)

Thanks.
I sent a mail to Mr Smith :), but haven't got a replay. The logical step would to bind what kind of type the property should be as an value on the property setting. Instead I needed to find the PageType when you access the Value and find by reflection the type.
It could also be possible to save the inner values inside these property settings, but as it turned out there are a few benifitts of saveing them as real properties. Copy, Export and so on....
/ Anders Hattestad

Guest
(By Guest, 9/21/2010 12:33:25 PM)

Seems like a good way to structure your pages into reusable components. Very cool!
/ Patrik Akselsson

mark.everard
(By mark.everard, 9/21/2010 12:33:25 PM)

Wow, what a great idea and implementation.

This is, from a code perspective rather than a persistence perspective, really beginning to stretch the EPiServer model beyond simple dictionary based PropertyBags.

Probably a big ask, but is there any way to go further and allow strongly typed access to List and Collection types. This will obviously present difficulties unless those collections were serializable, but that functionality would really be valuable.

Guest
(By Guest, 9/21/2010 12:33:25 PM)

There is a couple of ways of doing lists.
1) Itera.MultiProperty do save all sub properties as a string. The only issue is that we need a way populating the PageData object with it's value.
2) make a generic PropertyAnyClass class that use the ObjectDataStore. I have actully most of the implementasion ready, will post it as soon I can.

If any of you have managed to set a property setting on property from code, please let me know.
/ Anders Hattestad

Guest
(By Guest, 9/21/2010 12:33:25 PM)

What email? I haven't seen anything from you Anders.
/ Paul Smith

Guest
(By Guest, 9/21/2010 12:33:25 PM)

Guess it got cought in the crazy laughing programmer mail filter rule you have:)

was basicly a question about some example code for setting a property setting when all you had was the propertie def id

will resend
/ Anders Hattestad

Guest
(By Guest, 9/21/2010 12:33:25 PM)

My bad.
Had an error in paul smith's epost adress , so you can stop searching your email server :)
/ Anders Hattestad

Joel Abrahamsson
(By Joel Abrahamsson, 9/21/2010 12:33:25 PM)

Really interesting stuff! Will take a closer look at it as soon as I can. I'm also very interested in your question to Paul, so perhaps you, Paul, could post your reply as a blog post?

Joel Abrahamsson
(By Joel Abrahamsson, 9/21/2010 12:33:25 PM)

Oh and I'd also love to hear more about your experiences of building on top of/plugging into Page Type Builder!

Guest
(By Guest, 9/21/2010 12:33:25 PM)

Got an answar to how we should set properties on properties by code.
setting is the propertysetting class.

object setting=Activator.CreateInstance(EPiPropertySetting.PropertySettingType, EPiPropertySetting.PropertySettingArgument);
if (realProperty.SettingsID == Guid.Empty)
{
realProperty.SettingsID = Guid.NewGuid();
realProperty.Save();
}
var settingsContainer = new PropertySettingsContainer(realProperty.SettingsID);

settingsContainer.AddSettings(new PropertySettingsWrapper
{
PropertySettings = setting as IPropertySettings,
DisplayName = EPiPropertySetting.PropertySettingType.Name,
IsGlobal = false,
IsDefault = false
});

new PropertySettingsRepository().Save(settingsContainer);
/ Anders Hattestad

Erik Nordin Wahlberg
(By Erik Nordin Wahlberg, 9/21/2010 12:33:25 PM)

Anders! I removed a property from code, and now it crashes on startup.

Line 221: return (this.ClassAttribute.EditCaption == null ? Name : (this.ClassAttribute.EditCaption+"["+this.Name+"]")) + " (is " + this.ClassPropertyType.Name + " render as " + EPiPropertyType.Name + ")";
in PropertyInfoAndData.cs returns a null reference.

Erik Nordin Wahlberg
(By Erik Nordin Wahlberg, 9/21/2010 12:33:25 PM)

Sorry, that was not the issue.

I added a new property of the type int, but i did not declare a Type=typeof(PropertyNumber) when doing that. It caused a null reference to EPiPropertyType.

Bjørn Gustafson
(By Bjørn Gustafson, 7/21/2011 5:33:56 PM)

I saw your comment on this post, regarding PageTypePropertyGroups in PageTypeBuilder 2: http://world.episerver.com/Blogs/Lee-Crowe/Dates/2011/5/PageTypePropertyGroup-for-PageTypeBuilder-v2/

I am using PageTypePropertyGroups, but I love what you have done here by visually grouping the properties together in edit mode. Nice job! :-)

Do you have a version of your code which works with the new PageTypePropertyGroups in PageTypeBuilder 2?

lee.crowe
(By lee.crowe, 10/20/2011 3:43:46 PM)

Hi Bjorn

When PageTypeBuilder 2 is officially released I will release a new version of PageTypeBuilderUI. This will contain functionality similar to what Anders has done with his Itera.Objects project to lay the property group properties out in a nicer format.

Lee

Please login to comment.