Glass.Mapper
Glass.Mapper copied to clipboard
Glass Model not populated in after Glass Mapper upgrade
HI,
Previously we had a working solution using the following Glass packages:
Glass.Mapper 3.0.4.16 Glass.Mapper.Sc 3.0.5.14 Glass.Mapper.Sc.CastleWindsor 3.0.3.8
I've just updated to:
Glass.Mapper 3.0.15.32 Glass.Mapper.Sc 3.3.1.53 Glass.Mapper.Sc.CastleWindsor 3.3.1.26 Glass.Mapper.Sc.Mvc-4 3.3.1.48
Now I have an issue with certain Glass models not populating the property values.
Model is as follows: CallToAction.cs namespace IDP.Web.IDP.Models.Base { using System; using Base; using Glass.Mapper.Sc.Configuration.Attributes; using Glass.Mapper.Sc.Fields;
[SitecoreType(AutoMap = true)]
public class CallToAction : RenderingModel
{
public virtual string Title { get; set; }
public virtual string Text { get; set; }
public virtual Image Image { get; set; }
public virtual string LinkText { get; set; }
public virtual Glass.Mapper.Sc.Fields.Link LinkUrl { get; set; }
}
}
RenderingModel.cs namespace IDP.Web.IDP.Models.Base { using Glass.Mapper.Sc; using Sitecore.Data.Items; using Sitecore.Mvc.Presentation;
public abstract class RenderingModel : IRenderingModel
{
private SitecoreContext _context;
private Item _item;
private Item _pageItem;
public void Initialize(Rendering rendering)
{
Rendering = rendering;
InitializeModel();
}
public virtual void InitializeModel()
{
}
public SitecoreContext Context
{
get
{
if (_context == null)
{
_context = new SitecoreContext();
}
return _context;
}
}
public Item Item
{
get
{
if (_item == null)
{
_item = Rendering.Item;
}
return _item;
}
}
public Item PageItem
{
get
{
if (_pageItem == null)
{
_pageItem = Item;
}
return _item;
}
}
public Rendering Rendering { get; private set; }
}
}
Hi
Sorry for the slow reply. Are you still experiencing this problem?
Typically you wouldn't be using the IRenderingModel interface with a Glass model when working with a GlassView and MVC.
Mike
We are also facing same kind of issue after upgraded to 4. Using TDS to generate content model Below are the content Model. All fields are populated except Icon field.
Could you please update what could be the issued.
[SitecoreType(TemplateId="f4966ed9-8fb2-471a-acff-14d48aaab3d5")] public interface ISocialLink : IGlassBase {
[SitecoreField(ISocialLinkConstants.DestinationFieldName)]
Link Destination {get; set;}
[SitecoreField(ISocialLinkConstants.IconFieldName)]
SVGImage Icon {get; set;}
[SitecoreField(ISocialLinkConstants.MobileDestinationFieldName)]
Link MobileDestination {get; set;}
}
[SitecoreType(TemplateId="f4966ed9-8fb2-471a-acff-14d48aaab3d5")] public partial class SocialLink : GlassBase, ISocialLink {
public static ID TemplateID {get { return new ID("f4966ed9-8fb2-471a-acff-14d48aaab3d5"); }}
public static string TemplateNameStatic {get {return "SocialLink";}}
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Team Development for Sitecore - GlassItem.tt", "1.0")]
[SitecoreField("c1447e55-3
Dom.Compiler.GeneratedCodeAttribute("Team Development for Sitecore - GlassItem.tt", "1.0")] [SitecoreField("c1447e55-306d-4a76-a14c-c1faff9d3ccb")] public virtual Link Destination {get; set;}
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Team Development for Sitecore - GlassItem.tt", "1.0")]
[SitecoreField("6d621c4d-9863-4410-a68f-bb8a252c2792")]
public virtual SVGImage Icon {get; set;}
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Team Development for Sitecore - GlassItem.tt", "1.0")]
[SitecoreField("caade757-1cae-4fa0-b370-d71d20b81776")]
public virtual Link MobileDestination {get; set;}
}
Here is the new version of glass mapper and other components <package id="AutoMapper" version="3.3.1" targetFram ework="net451" /> <package id="Castle.Core" version="3.3.3" targetFramework="net451" /> <package id="Castle.Windsor" version="3.3.0" targetFramework="net451" /> <package id="dotless" version="1.4.1.0" targetFramework="net45" /> <package id="Flurl" version="1.0.5" targetFramework="net451" /> <package id="Glass.Mapper" version="3.0.15.32" targetFramework="net451" /> <package id="Glass.Mapper.Sc" version="4.0.11.63" targetFramework="net451" /> <package id="Glass.Mapper.Sc.CastleWindsor" version="3.3.1.26" targetFramework="net451" />