Tabs in initializemodule

Vote:
 

Read about tabs for epi7 preview (ttp://world.episerver.com/Forum/Developer-forum/EPiServer-7-Preview/Thread-Container/2012/10/Tabs-and-sort-index/) and tried to implement it on our epi 7.5 and ran into some problems:

StructureMap Exception Code: 202
No Default Instance defined for PluginFamily EPiServer.DataAbstraction.ITabDefinitionRepository, EPiServer, Version=7.6.5.0, Culture=neutral, PublicKeyToken=8fe83dea738b45b7

 

Looks like the problem is on this line:

 

var tabDefinitionRepository = ServiceLocator.Current.GetInstance<ITabDefinitionRepository>();

 

ANy idea what the problem is? added same code in alloy (version of epi is 7 I think) and it worked.

 

This is what I added:

 

[InitializableModule]
public class TabsInitializer : IInitializableModule
{

public void Initialize(InitializationEngine context)
{
var tabDefinitionRepository = ServiceLocator.Current.GetInstance<ITabDefinitionRepository>();

AddTabToList(tabDefinitionRepository, new TabDefinition() { Name = "Test", RequiredAccess = AccessLevel.Edit, SortIndex = 1000 });
}

public void Uninitialize(InitializationEngine context)
{
}

public void Preload(string[] parameters)
{
}

private void AddTabToList(ITabDefinitionRepository tabDefinitionRepository, TabDefinition definition)
{
TabDefinition existingTab = GetExistingTabDefinition(tabDefinitionRepository, definition);
if (existingTab != null)
{
definition.ID = existingTab.ID;
}
tabDefinitionRepository.Save(definition);
}

private static TabDefinition GetExistingTabDefinition(ITabDefinitionRepository tabDefinitionRepository, TabDefinition definition)
{
return tabDefinitionRepository.List()
.FirstOrDefault(
t =>
t.Name.Equals(definition.Name, StringComparison.InvariantCultureIgnoreCase));
}
}

#85287
Apr 22, 2014 13:15
Vote:
 

Hi, try decorating your module with: [ModuleDependency(typeof(EPiServer.Web.InitializationModule))] 

BR,

Marija

#85289
Apr 22, 2014 14:42
Vote:
 

That worked.

 

Thanks!

#85292
Apr 22, 2014 15:07
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.