Generic Selector Template URL for an Embedded Resource in a Class Library - Front- & Back-End Development - Front- & Back-End Development - Progress Community
 Front- & Back-End Development

Generic Selector Template URL for an Embedded Resource in a Class Library

  • Generic Selector Template URL for an Embedded Resource in a Class Library
  • I am walking through this example: Use a generic collection directive

    I am using a class library and embedded resources for all my content files, and this seems to work fine for the designer view templates and my resource files, but when i get to defining the selector I am a bit confused about how to resolve the url for the selector template:

    <sf-collection sf-data="items"
                   sf-identifier="Generic Selector Example"


    There is menu item for: Retrieve the URL reference to an embedded resource in the feather wiki, but there is nothing to find when you clink on the link. Watching the network in chrome developer tools, i see my templates pull like so:

    Request URL:http://localhost:60876/Telerik.Sitefinity.Frontend/Designer/View/List/GenericSelector?controlId=5573ef13-ff23-6150-95dd-ff00009b1489&package=TicketOmaha

     So I tried to mimic that behavior but without luck:


    Request URL:http://localhost:60876/Frontend-Assembly/Telerik.Sitefinity.Frontend/Designer/View/List/SfCollectionTemplate.html?package=TicketOmaha
    Request Method:GET
    Status Code:404 Not Found


    So does anyone have some guidance of advice? Do I need to implement my own embedded resource handler? I have done so before:

    public class ResourceRouteHandler : IRouteHandler
        IHttpHandler IRouteHandler.GetHttpHandler(RequestContext requestContext)
            return new EmbeddedResourceHttpHandler(requestContext.RouteData);
        public class EmbeddedResourceHttpHandler : IHttpHandler
            private readonly RouteData _routeData;
            public EmbeddedResourceHttpHandler(RouteData routeData)
                _routeData = routeData;
            public bool IsReusable
                get return false;
            public void ProcessRequest(HttpContext context)
                var group = _routeData.Values["group"].ToString();
                var fileName = _routeData.Values["file"].ToString();
                var fileExtension = _routeData.Values["extension"].ToString();
                if (!Regex.IsMatch(fileExtension, ("js|cs|png|sfhtml")))
                    throw new InvalidOperationException("Request not valid");
                var nameSpace = GetType().Assembly.GetName().Name;
                var manifestResourceName = string.Format("",
                    nameSpace, group, fileName, fileExtension);
                using (var stream = GetType().Assembly.GetManifestResourceStream(manifestResourceName))
                    if (fileExtension == "js")
                        context.Response.ContentType = "text/javascript";
                    else if (fileExtension == "css")
                        context.Response.ContentType = "text/css";
                    else if (fileExtension == "png")
                        context.Response.ContentType = "image/png";
                    Debug.Assert(stream != null, "stream != null");

  • There's another property for selectors: sf-template-assembly

    So the way to get this to work, from my experiementation, is:

    <sf-collection sf-data="items"
                   sf-identifier="Generic Selector Example"
                   sf-template-assembly="[Assembly Name]"
                   sf-template-url="[Folder Path To Resource Inside Assembly]/SfCollectionTemplate.html"></sf-collection>

  • Here's a working example:

    Assembly Name: ListWidget

    Path to Embedded Resource: MVC/Views/List/SfCollectionTemplate.html


    <sf-collection sf-data="items"
                   sf-identifier="Generic Selector Example"