November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Hmmm..... Looking here: https://world.optimizely.com/csclasslibraries/cms/EPiServer.Personalization.VisitorGroups.CriterionPropertyEditorAttribute?version=12
Should it be "CriterionPropertyEditorAttribute" (in the namespace EPiServer.Personalization.VisitorGroups) instead of "CriterionPropertyEditor"?
Hi,
The CriterionPropertyEditor attribute is new to CMS 12 so, if the 11.20.x tag you've added is correct and you're working on v11, you don't need that attribute. The documentation for v11 is here:
No problem.
For the sake of future-proofing the answer, I should point out that the newer version of that documentation for v11 can be found here:
Hmm, doing this:
[DojoWidget(WidgetType = "dijit.form.FilteringSelect", SelectionFactoryType = typeof(EnumSelectionFactory<MatchStringType>))]
public MatchStringType MatchType { get; set; }
gives me this:
[NullReferenceException: Object reference not set to an instance of an object.]
EPiServer.Personalization.VisitorGroups.DojoHtmlExtensions.DojoDropDownFor(HtmlHelper`1 html, PropertyInfo p, Object htmlAttributes, String label, String labelCssClass, LabelPosition labelPosition, DojoWidgetAttribute attr) +112
EPiServer.Personalization.VisitorGroups.DojoHtmlExtensions.DojoEditorFor(HtmlHelper`1 html, PropertyInfo propertyInfo, Object htmlAttributes, String label, String labelCssClass, LabelPosition labelPosition) +224
ASP.episerver_cms_views_shared_editortemplates_object_ascx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in D:\Projekt\Direktronik\Direktronik.se\Direktronik.Web\episerver\CMS\Views\Shared\EditorTemplates\Object.ascx:38
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +116
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +131
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +270
System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +74
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +131
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +9530
EnumSelectionFactory:
public class EnumSelectionFactory<TEnum> : ISelectionFactory
{
public IEnumerable<ISelectItem> GetSelections(
ExtendedMetadata metadata)
{
var values = Enum.GetValues(typeof(TEnum));
foreach (var value in values)
{
yield return new SelectItem
{
Text = this.GetValueName(value),
Value = value
};
}
}
private string GetValueName(object value)
{
var staticName = Enum.GetName(typeof(TEnum), value);
if (staticName != null)
{
string localizationPath = string.Format(
"/property/enum/{0}/{1}",
typeof(TEnum).Name.ToLowerInvariant(),
staticName.ToLowerInvariant());
string localizedName;
if (LocalizationService.Current.TryGetString(
localizationPath,
out localizedName))
{
return localizedName;
}
}
return staticName;
}
}
Any ideas?
/Kristoffer
Found the answer here!
https://world.optimizely.com/forum/developer-forum/CMS/Thread-Container/2016/5/criterion-null-reference-when-using-selectionfactorytype/
Unless you're doing something special, you shouldn't need to create a new EnumSelectionFactory as there's already one ready-to-use in EPiServer.Web.Mvc.VisitorGroups.EnumSelectionFactory.
Hi!
I'm trying to create my own criteria using this article:
https://world.optimizely.com/documentation/developer-guides/CMS/personalization/developing-custom-visitor-group-criteria/
But I cannot find any reference to CriterionPropertyEditor?
Gives me error that CriterionPropertyEditor cannot be found are you missing reference? I what namespace is CriterionPropertyEditor located?
Thanks!
/Kristoffer