Custom module not loading any views in admin

Posted by Community Admin on 04-Aug-2018 16:00

Custom module not loading any views in admin

All Replies

Posted by Community Admin on 01-Jul-2011 00:00

Hi,

Don't know about anyone else but i feel like i am losing the will to live building custom modules in 4.1. i can see the potential, and I am sure it is me just not getting it at the moment, but i have spent the last 4 days working on a custom module, well i say 4 days, it took 1 day to code and the other 3 i have just been staring at the same issue (picture attached) where i am recieving no errors and am really confused as to what i have missed, i know i have missed something i am just not sure what that is, and the lack of error messages just makes a needle in a haystack to find out what i have done wrong.

I got to the section, but thats all i get, go to the backend pages and its the same, it is like the views i defined in code are not being pulled in or something, but i have followed the ProductsModule.

Please help!!!

Rob

Posted by Community Admin on 01-Jul-2011 00:00

More investigation and i seem to recieving a Javascript error:

this._currentItemsList is undefined
Break @ : this._currentItemsList.set_title(this._titleText);

Rob

Posted by Community Admin on 04-Jul-2011 00:00

Anyone????

i have attached a new control project file to my support ticket (if anyone from support would like to look at this, the last one one has been sitting there since Friday)  i went through the code again and there were some ommissions and mistakes, nothing it seems that would stop the views from appearing, but i have obviously missed something else, but i have no idea what, i based my module on the products module (bar the comments elements which were commented out), the problem i am having is i cant debug something that gives me no feedback, i feel like i am looking for a needle in a pile of needles at the moment, and having spent 6 days on this every day looking at the same screen with no improvement, i know this is my issue as i have obviously not done something or put something in incorrectly but the lack of debugging is not helping me.  I understand you guys cant be debugging everyones code, i just have no idea what could be causing this or where to even begin looking to fix.

I could really do with a little bit of help, from anyone on this.

Rob

Posted by Community Admin on 05-Jul-2011 00:00

I have figured this out, i knew i was missing something, and it would be something stupid, but i guess looking at the same code for six days can do that to you.  If anyone else has something similar where you are recieving the javascript error above and the screen is blank (apart from the SF header and footer), check that you have created the SetRootPermissions overload in you DataProviderClass Thats what i was missing, not sure how i missed it as its a meaty method, not just a wrapper, i also had to remove and re-add the module and i am getting my module screen now in the admin, there are some resource issues but i will go through and see if i can figure those out.

Rob

Posted by Community Admin on 06-Jul-2011 00:00

I just ran into this today as well, but I do have the overload for SetRootPermissions. Was there anything else you needed to check?

Posted by Community Admin on 06-Jul-2011 00:00

Hi Kristian,

Are you recieving the javascript error aswell? 

To be honest the SetRootPermissions was the last thing that i did that finally fixed it (although i had over issues after),  does your override contain any code (mine is attached below)? but there were some other issues with my code, some decorators for classes missing, OpenAccess declarations in the model missing etc, i just had to go through it all again and again.  the only other thing i can suggest is to compare you code against the products module, but also read through the documentation on creating the products module (thats how i saw SetRootPermissions was missing), this stuff is really blind, with no error messages it is like i said looking for a needle in a pile of needles you may have to go through the frustration of looking at code untill you finally find the items that are missing, maybe the team at Telerik can get these things to throw some errors, not sure that is really practical but would help in situations like this.

Also, if you make changes, you pretty much have to reinstall the module on a clean install, as for some reason removing it and reinstalling it doesnt always work.

Just some tips (you may be doing some of this already), What we have been doing is creating throw away projects and testing against that, not using out core project as it is a pain to remove modules (hopefully this will be corrected in 4.2) and they will not be installed untill they do everything we need, so situations like this where we have to reload and check reload and check become annoying but less of a pain.  Also Firebug saves my life most days, and has helped with 4.0 dev.

Sorry that is not much help, but honestly if i could pin point it to one thing i would.

if (root.Permissions != null || root.Permissions.Count > 0)
    root.Permissions.Clear();
 
var appRoles = Config.Get<SecurityConfig>().ApplicationRoles;
var everyoneRoleId = appRoles[SecurityConstants.AppRoles.Everyone].Id;
var authorsRoleId = appRoles[SecurityConstants.AppRoles.Authors].Id;
var editorsRoleId = appRoles[SecurityConstants.AppRoles.Editors].Id;
 
//Location Permissions
var permissionsforEveryoneToViewLocations = this.CreatePermission(LocationConstants.Security.PermissionSetName, root.Id, everyoneRoleId);
permissionsforEveryoneToViewLocations.GrantActions(false, LocationConstants.Security.View);
root.Permissions.Add(permissionsforEveryoneToViewLocations);
 
var permissionsForOwnersToModifyAndDeleteLocations = this.CreatePermission(LocationConstants.Security.PermissionSetName, root.Id, SecurityManager.OwnerRole.Id);
permissionsForOwnersToModifyAndDeleteLocations.GrantActions(false, LocationConstants.Security.Modify, LocationConstants.Security.Delete);
root.Permissions.Add(permissionsForOwnersToModifyAndDeleteLocations);
 
var editorsPermissionsForProducts = this.CreatePermission(LocationConstants.Security.PermissionSetName, root.Id, editorsRoleId);
editorsPermissionsForProducts.GrantActions(
    false,
    LocationConstants.Security.Create,
    LocationConstants.Security.Modify,
    LocationConstants.Security.Delete,
    LocationConstants.Security.ChangeOwner);
root.Permissions.Add(editorsPermissionsForProducts);
 
var authorsPermissionsForLocations = this.CreatePermission(LocationConstants.Security.PermissionSetName, root.Id, authorsRoleId);
authorsPermissionsForLocations.GrantActions(false, LocationConstants.Security.Create);
root.Permissions.Add(authorsPermissionsForLocations);

Posted by Community Admin on 06-Jul-2011 00:00

Yes, I also get this._currentItemsList is undefined during the set_titleText call. Thanks for your help, my SetRootPermissions is the same as yours and I still receive that error, so there must be something else. I will post it when I find it.

The sad part of it is, I've created a few modules already, and they work fine, all based off the products module... and now I get hit with this it is frustrating.

I'm glad I am not the only one finding that getting a module to run is a pain. I've been doing the same, creating a throw away project dedicated to the module I am working on until I get it to work. I can't get reinstalls to work either. The other (non-javascript) errors I can handle just fine, but like you said this is like looking for a needle in a haystack. Also, I found that if you want to go back and say 'add a new field' to your module it will blow up when trying to run it again. So I make sure I add as many fields as I need from the get go. There is this 'Upgrade' method, but I'm not sure how to implement new fields to an existing module that is already installed on a project.

/// <summary>
/// Upgrades this module from the specified version.
/// </summary>
/// <param name="initializer">The Site Initializer. A helper class for installing Sitefinity modules.</param>
/// <param name="upgradeFrom">The version this module us upgrading from.</param>
public override void Upgrade(SiteInitializer initializer, Version upgradeFrom)


I like firebug too, but if you set IE as the default browser when debugging your project it will break into visual studio during the javascript call and from there you can investigate you can set watches, inspect elements etc. like you can in your normal server code.

Ok that's enough ranting for now!

Posted by Community Admin on 08-Jul-2011 00:00

Hello Kristian,

To add new fields to your module and avoid errors you have to register them in both ModuleDefinitions.cs and ModuleResources.cs. If you miss one you will get a blank screen for your module as described in the first post.
Please refer to the products module as I will make my example with it.
You have this definition when you enter title for Product Item

var titleField = new TextFieldDefinitionElement(mainSection.Fields)
            
                ID = "titleFieldControl",
                DataFieldName = "Title",
                DisplayMode = displayMode,
                Title = "lTitle",
                CssClass = "sfTitleField",
                ResourceClassId = typeof(ArticlesResources).Name,
                WrapperTag = HtmlTextWriterTag.Li,
            ;
The highlighted text shows you it is suing resources so go to ProductsResources.cs and find the resource entry.
[ResourceEntry("lTitle",
            Value = "Title",
            Description = "phrase: Title",
            LastModified = "2010/12/09")]
        public string lTitle
        
            get return this["lTitle"];
        
If you want this text box to be called Name you have to make changes in both places. If you create new definition make sure you create a resource entry too.

Kind regards,
Stanislav Velikov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed