Recently, I've begun updating a FubuMVC project from a pre-May/June 2010 version of the FubuMVC framework to the most recent version.
One of the biggest stumbling blocks I'm running into is how to configure FubuControls and the display models they use so that I can render those controls in a Site.Master page. The one FubuException error message I have trouble getting around is:
FubuMVC Error 2102:
Unknown input type ResourceDisplay
thrown from method FindUniqueByInputType in FubuMVC.Core.Registration.Querying.ChainResolver line 69.
Here's my Global.asax.cs for the web project:
public class Global : FubuStructureMapApplication
{
protected override void InitializeStructureMap(IInitializationExpression ex)
{
Bootstrapper.ScanAndRegisterTypesForStructureMap(ex, new List<Registry>
{
new WebAppWebRegistry(),
new AppSettingProviderRegistry()
});
setup_service_locator();
}
private static void setup_service_locator()
{
ServiceLocator.SetLocatorProvider(() => new StructureMapServiceLocator(ObjectFactory.Container));
}
public override FubuRegistry GetMyRegistry()
{
return new WebAppFubuRegistry();
}
}
Here's my FubuRegistry:
public class WebAppFubuRegistry : FubuRegistry
{
public WebAppFubuRegistry()
{
IncludeDiagnostics(true);
Services(x => x.SetServiceIfNone<IWebAppSecurityContext, WebAppSecurityContext>());
Applies.ToThisAssembly()
.ToAssemblyContainingType<HomeController>();
Actions
.IncludeTypesNamed(x => x.EndsWith("Controller"));
Routes
.UrlPolicy<WebAppUrlPolicy>()
.IgnoreControllerNamespaceEntirely()
.ConstrainToHttpMethod(action => action.Method.Name.StartsWith("Perform"), "POST");
Views
.TryToAttach(x=>
{
x.by<ViewAndActionInDifferentFolders>();
x.by_ViewModel_and_Namespace_and_MethodName();
x.by_ViewModel_and_Namespace();
x.by_ViewModel();
});
/* Irrelevant behaviors are added to configuration here */
RegisterPartials(x => x.For<ResourceDisplay>().Use<ResourceTracker>());
//this.UseDefaultHtmlConventions();
//HomeIs<HomeController>(x => x.Index());
}
}
More information and update:
Part of the problem I discovered was that when I was updating the project I changed:
public class SiteMasterView : FubuMasterPage<EmptyModel>, IFubuPage<EmptyModel>{ }
to
public class SiteMasterView : FubuMasterPage
which meant that the extensions function RenderPartial<TViewModel>(this IFubuPage<TViewModel> viewPage) was no longer usable from SiteMasterView.
Here's the old and invalid RenderPartial<TViewModel> Call in Site.Master:
<%= this.RenderPartial().Using<ResourceTracker>().For(Get<UserResources>().Resources)%>
So, I think at this point I considered trying to create my own RenderPartial extension function that would work with FubuMasterPage (instead of just with IFubuPage<EmptyModel>). But I figured I might as well update my usage of the FubuFramework and use the void Partial<TInputModel>(this IFubuPage page) where TInputModel : class; extension function instead of the older more verbose version.
The new call:
<% this.Partial<ResourceDisplay>(); %>
That's when I began running into the error emitted by the ChainResolver, and I tried a variety of solutions, including creating an implementation of IFubuCommand that generated a ResourceDisplay. Also I attempted to register the partial explicitly in my FubuRegistry. But I've had no luck in getting past the ChainResolver.
What is the preferred way to register FubuControls and their view models with the FubuFramework?
How do I fix the error mentioned above?