Try our conversational search powered by Generative AI!

New PropertyList<T> EPiServer 11

Vote:
 

Hi,

I have the below code 

public class SocialMediaItem : IHasImage
{
[UIHint(UIHint.Image)]
[Required]
[Display(Name = "Social Media Image", Order = 10)]
public ContentReference Image { get; set; }

[Required]
[Display(Order = 20)]
public string Name { get; set; }


[Required]
[Display(Order = 30)]
public Url Url { get; set; }
}

[PropertyDefinitionTypePlugIn]
public class SocialMediaItemListProperty : PropertyListBase
{
}

public class PropertyListBase : PropertyList
{
private readonly IObjectSerializer _objectSerializer;

private Injected _objectSerializerFactory;

public PropertyListBase()
{
this._objectSerializer = this._objectSerializerFactory.Service.GetSerializer("application/json");
}

protected override T ParseItem(string value)
{
return this._objectSerializer.Deserialize(value);
}

public override PropertyData ParseToObject(string value)
{
this.ParseToSelf(value);

return this;
}
}

This code was working fine without any issues in EPiServer 10.10.4 version.

However after upgrading to EPiServer 11, the URL property data is not saving any data and throwing an exception. The Breaking changes telling that to use JsonConverter. Could you please tell me how to use JsonConverter to the existing propertylist and what should be done in the PropertyListbase to save Url property data.

#186537
Dec 21, 2017 23:22
Vote:
 

We have the same problem. Did you find a solution?

#186727
Jan 03, 2018 13:12
Vote:
 

Hi 

In my situation creating silple plugin works like a charm :

[PropertyDefinitionTypePlugIn]
public class PersonListProperty : PropertyList<Person>
{
}

I am using epi in ver 11.2.1.0. 

#186742
Jan 03, 2018 15:21
Vote:
 

Same problem here.

Any solutions?

string-property works. But not Url-property...

#187092
Edited, Jan 11, 2018 15:43
Vote:
 

Finally!

First: We dont need PropertyListBase<T>.

Second (the real solution):

[JsonProperty]
[JsonConverter(typeof(UrlConverter))]
[Display(Name = "Links", Order = 400)]
public virtual Url UrlLink { get; set; }



UrlConverter: 

using EPiServer.Cms.Shell.Json.Internal;



#187118
Jan 12, 2018 9:24
Vote:
 

Empa,

Do you know how you can use this on an xhtmlstring?   

#189990
Mar 28, 2018 19:42
Vote:
 

Hi Valina,

I think there was nothing tricky to setup PropertyList with XHTML field, simply just add property

    

   public XhtmlString Content { get; set; }



I only remember there was an issue with layout, when you have opened popup window to add/edit an item, but easily possible to fix with some CSS tweaking, see here

#190188
Edited, Apr 04, 2018 14:27
Vote:
 

Surely there must be a better way to be able to use a Url property in a property list without having to use an internal API which might break or change at any moment?

#190195
Apr 04, 2018 16:25
Vote:
 

That's what I was trying to do, but every time I add an xhtml string the property list isn't loading at all, or the property list is jsut appearing blank and I'm unable to edit anything.  

If i make it a general string, it works fine (But this wont work)

I just updated to 11.4 and am still having this issue.

Error in property list

Apprently it is throwing an exception when I try to make an xhtml string: Unable to load /EPiServer/shell/Stores/metadata/ep…lock2?dojo.preventCache=1522853523782 status: 500

The stack trace of this exception is:

[ArgumentNullException: Value cannot be null.
Parameter name: subject]

EPiServer.RuntimeModelExtensions.GetOriginalType(Object subject) +107 EPiServer.Cms.TinyMce.Core.TinyMceConfiguration.Get(T model, String propertyName) +13 EPiServer.Cms.TinyMce.Core.XhtmlStringEditorDescriptor.ModifyMetadata(ExtendedMetadata metadata, IEnumerable`1 attributes) +109 EPiServer.Shell.ObjectEditing.ExtensibleMetadataProvider.ApplyExtendersToMetadata(ExtendedMetadata metadata, IEnumerable`1 attributes, IEnumerable`1 metadataHandlers) +97 EPiServer.Shell.ObjectEditing.ExtensibleMetadataProvider.CreateMetadata(IEnumerable`1 attributes, Type containerType, Func`1 modelAccessor, Type modelType, String propertyName) +411

I wonder if this has something to do with the new TinyMCE implimentation. 

#190196
Edited, Apr 04, 2018 16:48
Vote:
 

Maybe you can try to post how your code looks like.

Another thing is that I did not update EPiServer.CMS.TinyMce to version 2.0.0 yet, did you? if so worth to check blog posts about that e.g. here or here

#190206
Apr 04, 2018 20:36
Vote:
 

Hi Grzegorz,

Thanks for the reply.

The code is pretty simple and straightforward for property lists, so I don't know what could be going on

public class AccordionBlock2
	{
		public string Headline { get; set; }
	
		public XhtmlString Body { get; set; }
	}
[Display(
		 Name = "Accordion Items 2",
		 Description = "Accordion Items 2",
		 GroupName = SystemTabNames.Content,
		 Order = 10)]
			[EditorDescriptor(EditorDescriptorType = typeof(CollectionEditorDescriptor<AccordionBlock2>))]
	
		public virtual  IList<AccordionBlock2>  AccordionItems2 { get; set; }



public class AccordionPropertyDefinition
	{
		[PropertyDefinitionTypePlugIn]
		public class AccordionProperty : PropertyListBase<AccordionBlock2>
		{

		}
		
	}

Thank you  for those blog posts!! I was working on the  TinyMCE 2.0.0 and what you posted has been really helpful!

Thanks again,

#190207
Apr 04, 2018 20:47
Vote:
 

The PropertyList<T> as most of you would know is based on JSON-serialization. But it may not be as obvious that the JSON representation is used in three different places; communication between client and server, in the database, and as the export format. These different cases sometimes come with slightly different requirements, which is especially true when it comes to XhtmlStrings and URLs. Features such as permanent links, link tracking and cross-package link support require custom and sometimes complex JsonConvert implementations.

So be aware that even if you can get the UI to work there may be other areas that are not fully functional.

When we updated PropertyList<T> for CMS 11 we unfortunately didn't have time to add support for these features for XhtmlStrings and URLs as we focused on getting the experience right for simple properties first.

So if you want support for a URL property on your list items and use the UrlConverter in the EPiServer.Cms.Shell.Json.Internal, you should know that it was written to only support the client/server use case and that it doesn't have any support for the other features that a URL property on a content item support.

And if you want XhtmlString support my recommendation at this time would be to drop the PropertyList<T> and use blocks and content areas instead unless you are feeling up for a challenge.

Side note: if you also want support for adding default property values in the Admin UI, you have to override the ParseItem method on your PropertyList and make sure that it can parse the format that the ToString method of the list item type outputs. We removed the requirement to implement this method in CMS 11 as most implementations got it wrong anyway.

#190213
Edited, Apr 05, 2018 0:49
Vote:
 

Hi Valina,

You could try to get rid of using PropertyListBase since you are already running version 11.4 your class might be something like

[PropertyDefinitionTypePlugIn]
public class AccordionProperty : PropertyList<AccordionBlock2>
{

}



Check also that thread about loosing data in PropertyList and fix made in release 208 regarding that bug

#190219
Edited, Apr 05, 2018 7:49
Vote:
 

Thank you for the clarification Henrik

I went ahead and used the blocks within blocks to get these accordions to work. While not the best way of solving this problem it works and I don't have to spend more time on this. I'll wait until xhtmlstrings are offically supporting as to not break things more in the futre :)  I'm pretty good at breaking things as it is, so I don't need more help with that!

#190342
Apr 09, 2018 19:09
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.