+1-888-365-2779
Try Now
More in this section

Forums / General Discussions / Products Module Exception

Products Module Exception

6 posts, 1 answered
  1. Sergio
    Sergio avatar
    21 posts
    Registered:
    02 Feb 2009
    02 Sep 2009
    Link to this post
    Dear Sirs,
    using the Products module, if we click a category in the category list,
    we get the following exception:

    The ViewMode "ContentItemsView" is not defined for this control.
    System.ArgumentException: The ViewMode "ContentItemsView" is not defined for this control.

    Could you please help me?
    Thank you very much for your help.
    Best Regards,
    Sergio
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    02 Sep 2009
    Link to this post
    Hello Sergio,

    Please make sure that your CategoriesView looks like as shown  below:

    using System; 
    using Telerik.Cms.Engine.WebControls.Admin; 
    using Telerik.Samples.Products.WebControls.Admin.Products; 
     
    namespace Telerik.Samples.Products.WebControls.Admin 
        /// <summary> 
        /// Categories View for products module 
        /// </summary> 
        public class ProductsCategoriesView : CategoriesView<ProductsControlPanel> 
        { 
     
        
            /* 
                Since we will completely reuse the base CategoriesView, we also wish to use the
                resources embedded in Telerik.Cms.Engine assembly for CategoriesView (such as
                localization, templates, css, javascripts... In order to do so, we need to override
                the AssemblyInfo and LocalizationAssemblyInfo and return any type from Telerik.Cms.Engine
                assembly, because if we don't do that, Sitefinity will automatically determine the view
                to be part of the Telerik.Samples.Assembly and we will get missing resources exception.
                Alternatively, we could move all the resources in this assembly.
            */ 
     
     
            /// <summary> 
            /// Gets the type from the assembly containing the embedded resources. 
            /// Cannot be null reference. 
            /// </summary> 
            /// <value></value> 
            public override Type AssemblyInfo 
            { 
                get 
                { 
                    return typeof(GenericControlPanel); 
                } 
                set 
                { 
                    base.AssemblyInfo = value; 
                } 
            } 
     
            /// <summary> 
            /// Gets the type from the assembly containing the embedded localization resource. 
            /// Override if embedded templates are using ASP.NET localization. 
            /// </summary> 
            /// <value></value> 
            public override Type LocalizationAssemblyInfo 
            { 
                get 
                { 
                    return typeof(GenericControlPanel); 
                } 
                set 
                { 
                    base.LocalizationAssemblyInfo = value; 
                } 
            } 
     
            protected override void RedirectOnOpenContent(string filterExpr) 
            { 
                NavigateHostCommand<ProductsView>(filterExpr); 
            } 
     
        } 

    the same applies for ProductsControlPanel class

    using Telerik.Cms.Engine; 
    using Telerik.Cms.Engine.WebControls.Admin; 
    using Telerik.Cms.Web.UI.Backend; 
    using Telerik.Samples.Products.Resources; 
     
    namespace Telerik.Samples.Products.WebControls.Admin 
        /// <summary> 
        /// Control panel for the products module 
        /// </summary> 
        public class ProductsControlPanel : ProviderControlPanel<ProductsControlPanel>, IGenericContentHost 
        { 
            /// <summary> 
            /// Gets or sets the title of the panel containing the data provider selector. 
            /// Usually this is the first command panel on the top right side of the control panel. 
            /// </summary> 
            /// <value></value> 
            public override string ProviderSelectorPanelTitle 
            { 
                get 
                { 
                    return Messages.ExploreProducts; 
                } 
                set 
                { 
                    base.ProviderSelectorPanelTitle = value; 
                } 
            } 
     
            /// <summary> 
            /// Loads configured views. 
            /// </summary> 
            protected override void CreateViews() 
            { 
                AddView<ProductsView>("ProductsView""ProductsView_Title""ProductsView_Description""all", Messages.ResourceManager); 
                AddView<ProductsCategoriesView>("ProductsCategoriesView""CategoriesView_Title""CategoriesView_Description""all", Messages.ResourceManager); 
                AddView<ProductsTagsView>("ProductsTagsView""TagsView_Title""TagsView_Description""all", Messages.ResourceManager); 
                AddView<ProductsCommentsView>("ProductsCommentsView""CommentsView_Title""CommentsView_Description""all", Messages.ResourceManager); 
                AddView<ProductsPermissionsView>("ProductsPermissionsView""PermissionsView_Title""PermissionsView_Description""globalPerm", Messages.ResourceManager); 
            } 
     
            /// <summary> 
            /// Content Manager used by the control 
            /// </summary> 
            public ContentManager Manager 
            { 
                get 
                { 
                    return this.ProductsManager.Content; 
                } 
            } 
     
            /// <summary> 
            /// Gets the products manager. 
            /// </summary> 
            /// <value>The products manager.</value> 
            public ProductsManager ProductsManager 
            { 
                get 
                { 
                    if(this.productsManager == null
                        this.productsManager = new ProductsManager(this.ProviderName); 
                    return this.productsManager; 
                } 
            } 
     
            /// <summary> 
            /// When overridden this method returns the name of the default data provider for the module. 
            /// Default data provider is used when no current provider is selected. 
            /// The default implementation returns empty string. 
            /// </summary> 
            /// <returns> 
            /// A string representing the name of the default data provider for the module. 
            /// </returns> 
            protected override string GetDefaultProviderName() 
            { 
                return ProductsManager.DefaultContentProvider; 
            } 
             
            private ProductsManager productsManager; 
        } 
     


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Answered
  3. bemara57
    bemara57 avatar
    135 posts
    Registered:
    27 Mar 2008
    24 Jan 2010
    Link to this post
    That worked for me- thanks for the fix!!

    There is another exception happening when going to Comments and editting a comment. When clicking cancel here, the page crashes with this exception:

    System.ArgumentException: The ViewMode "GenericControlPanel" is not defined for this control.

    I'm thinking that it's trying to go to the preview page like it does with the products scenario (since it's overriding this), but since comments preview doesn't exist, I'm trying to override "GetPreviewCommand()" method to just take me to the CommentView list. I don't know where to put this or if this is the right appraoch. Any suggestions or advice would be greatly appreciated.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    25 Jan 2010
    Link to this post
    Hello bemara57,

    You need to implement the following views

    CommentsList
    CommentsEdit
    CommentsPreview

    below is a sample implementation on two of three

    namespace Telerik.Samples.Products.WebControls.Admin
    {
        /// <summary>
        /// Comments view for the products module
        /// </summary>
        public class ProductsCommentsView : CommentsView<ProductsControlPanel>
        {
     
            public override Type AssemblyInfo
            {
                get
                {
                    return typeof(GenericControlPanel);
                }
                set
                {
                    base.AssemblyInfo = value;
                }
            }
     
     
            public override Type LocalizationAssemblyInfo
            {
                get
                {
                    return typeof(GenericControlPanel);
                }
                set
                {
                    base.LocalizationAssemblyInfo = value;
                }
            }
     
            protected override void CreateViews()
            {
                AddView<ProductsCommentsList>();
                AddView<ProductsCommentsEdit>();
                //AddView<ProductsCommentsPreview>();
            }
        }
    }


    ProductsCommentsList

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Telerik.Cms.Engine.WebControls.Admin;
    using Telerik.Samples.Products.WebControls.Admin.Products;
     
    namespace Telerik.Samples.Products.WebControls.Admin
    {
        class ProductsCommentsList : CommentsList<ProductsCommentsView>
        {
            /// <summary>
            /// Gets or sets the path to a custom layout template for the control.
            /// </summary>
            /// <value></value>
            [WebSysTemplate(ProductsCommentsList.ProductsCommentsListTemplateName, "ProductsCommentsListTemplateName_Desc", "/Products", false, "2009-01-28")]
            public override string LayoutTemplatePath
            {
                get
                {
                    return base.LayoutTemplatePath;
                }
                set
                {
                    base.LayoutTemplatePath = value;
                }
            }
     
            /// <summary>
            /// Gets the name of the embedded layout template. This property must be overridden to provide the path (key) to an embedded resource file.
            /// </summary>
            /// <value></value>
            protected override string LayoutTemplateName
            {
                get
                {
                    return ProductsCommentsList.ProductsCommentsListTemplateName;
                }
            }
     
            protected override string GetEditCommentCommand(string commentId)
            {
                return CreateHostViewCommand<ProductsCommentsEdit>(commentId);
            }
     
            protected override string GetParentItemCommand(string commentParentId)
            {
                return CreateRootViewCommand(commentParentId,
                                      typeof(ProductsControlPanel),
                                      typeof(ProductsItemListView),
                                      typeof(ProductPreviewView));
            }
     
            private const string ProductsCommentsListTemplateName =
                "Telerik.Samples.Products.Resources.ControlTemplates.Backend.CommentsList.ascx";
        }
    }

    ProductsCommentsEdit

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Telerik.Cms.Engine.WebControls.Admin;
    using Telerik.Samples.Products.WebControls.Admin.Products;
     
    namespace Telerik.Samples.Products.WebControls.Admin
    {
        class ProductsCommentsEdit : CommentsEdit<ProductsCommentsView>
        {
     
            [WebSysTemplate(ProductsCommentsEdit.ProductsCommentsEditTemplateName, "ProductsCommentsEditTemplateName_Desc", "/Products", false, "2009-01-28")]
            public override string LayoutTemplatePath
            {
                get
                {
                    return base.LayoutTemplatePath;
                }
                set
                {
                    base.LayoutTemplatePath = value;
                }
            }
     
            protected override string LayoutTemplateName
            {
                get
                {
                    return ProductsCommentsEdit.ProductsCommentsEditTemplateName;
                }
            }
            
     
            protected override string GetParentItemCommand(string commentParentId)
            {
                return CreateRootViewCommand(commentParentId,
                                             typeof(ProductsControlPanel),
                                             typeof(ProductsItemListView),
                                             typeof(ProductPreviewView));
            }
     
            protected override string GetCancelCommand()
            {
                return CreateRootViewCommand(typeof(ProductsControlPanel),
                                             typeof(ProductsCommentsView));
            }
     
            protected override void RedirectOnSave(string message)
            {
                NavigateHostCommand<ProductsCommentsList>(null, message);
            }
     
     
            private const string ProductsCommentsEditTemplateName =
                "Telerik.Samples.Products.Resources.ControlTemplates.Backend.CommentsEdit.ascx";
        }
    }

    You can get the templates from GenericContent module.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Hanadi
    Hanadi avatar
    6 posts
    Registered:
    17 Jan 2008
    21 Mar 2010
    Link to this post

    Why exactly do we have to implement these views?( CommentsList, CommentsEdit, CommentsPreview )
    Everything works fine except for the "Content item" link, which fails with the error mentioned above: System.ArgumentException: The ViewMode "GenericControlPanel" is not defined for this control.

    I thought the whole point of the new architecture was reuse of views. If I don't need to change anything I shouldn't have to implement anything.
    here's a quote from another blog entry found here:
    http://www.sitefinity.com/blogs/ivan/posts/09-03-21/products_module_reusing_views.aspx

    Completely reusing Views

    Sometimes we don’t need to change anything on the base implementation of the View. In such cases the simplest thing to do is to completely reuse the View.  A good example of this approach are the comment Views. Namely, CommentsView View located implemented on Generic Content module has three child views:

    • CommentsList
    • CommentsEdit and
    • CommentsPreview

    Since we don’t need to change anything on the three child views, we have simply implemented ProductCommentsView  by inheriting CommentsView container view. 

    I tested this with 3.7 SP3 Community

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    22 Mar 2010
    Link to this post
    Hi Hanadi,

    You need to inherit from the base views as shown below, because the Control panel of the module is not GenericControlPanel. It is ProductsControlPanel. Basically the minimal implementation is required to get the proper navigate host commands. 

    All the best,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
6 posts, 1 answered