Saturday, March 26, 2016

Sitecore Entity Service - Stack Overflow Exception

There is a very fine print in Sitecore Entity Service documentation available here as mentioned below

Note that an entity cannot contain a property of a type that is derived from Sitecore.Services.Core.Model.EntityIdentity.

There may be more behind this statement based on my experiment with entity service.

In one of my entity service the entity I was implementing, inheriting from EntityIdentity, I had list of weekdays selected by the end user and I used Days of week list to avoid creating my own list of items. Property looked like this

        private List<Item> _daysOfWeek;
        public List<Item> DaysOfWeeks
        {
            get
            {
                if (_daysOfWeek == null)
                    _daysOfWeek = new List<Item>();
                
                return _daysOfWeek;
            }
            set { _daysOfWeek = value; }
        }

Item could be any other Sitecore Item (system defined OR your own)

Now from my page code javascript when my entity service is trying to fetch an entity, it is not even hitting the FindById method of my repository inheriting from
Sitecore.Services.Core.IRepository
and the worker process crashes by throwing stack overflow exception.

Finally, I had to create my own class having itemId, itemName and certain other properties as a POCO class and had to write my own transformation logic to and from Sitecore items to my this entity. This resolved the problem

Hope this will help other people working on Sitecore Entity Service and facing StackOverflowException crashing their worker process (w3wp.exe)



Saturday, March 12, 2016

SPEAK Common Navigation Menu

Usually in your Sitecore SPEAK application you may have more than one pages in the application. Like any other application how do you tie them together through a common navigation which you want to maintain at one place rather than repeating it on every page. Here is a small post which will help you in achieving that.


  1. Let us assume you have 3 pages in a SPEAK application called "NewApp" as shown in the Pages folder in the picture below


  2. Speak Application Structure
    Speak Application Structure
  3. I also created a Navigation folder to maintain navigation related items in one place. This folder contains items of type "HyperlinkButton Parameters" and I added 3 items one for each page as shown below


  4. Adding-Navigation-Item

  5. Now configure each HyperlinkButton parameter item to point to a page you want to navigate to in its properties windows (when you double click that item in Sitecore Rocks - Sitecore explorer) - as shown below


  6. Configuring-HyperlinkButton-Parameter

  7. Do the same thing for Dashboard and EventListing pages


  8. Now setup the HyperlinkButton group on the Dashboard page with placeholder key as ApplicationContent.Navigation and Datasource location as shown below



  9. HyperlinkButtonGroup-Configuration


  10. Set the SelectedItemId of HyperlinkButton Group component to the the Dashboard Hyperlinkbutton properties definition item as shown in the above diagram


  11. Repeat steps 5 and 6 for Event Listing and Event Detail page setting SelectedItemID to respective Hyperlinkbutton properties definition item. If on other pages you dont have ApplicationContentNM or ApplicationContentNMI components - you may need to replace ApplicationContentMI component with the one of these two to have ApplicationContent.Navigation placeholder available for you to assign your HyperlinkButtonGroup component in that placeholder.


  12. Finally it should look like this


  13. Final-SPEAK-Common-Navigation-App


Hope this helps.