Slow Loading of page Mojo

Primary tabs

ZEN, Caché

Hi,

I have a Zen Mojo application that haves a tree menu, in this menu I'm loading all records from database (about 1500) and the page is very slow, about 2 seconds to load, I don't know how to get faster.

Replies

Have you checked how much time does it take to load all records from database on a server?

Hi Andrei!

Although I understand your problem, I didn´t get exactely what you  want. Anyway, there is an example on SAMPLES namespace (ZMdemo.bootstrap.HomePageServerSide.cls ) that demonstrates how to get your layout and data content from the server side. To do that yoy just to return null con getContent javascript method.

Please let me know if it helps otherwise provide additional details about what you realy expect to do.

Regards 

Actually I get all of my pages of the server side, it's all working, but I have this menu that is causing the page to load very slowly, it's taking too much time to load all contents, and I don't know how to upgrade this. I have to load the menu in every page, is there a way to load subcontents only after I click in a collapsible in menu.

Can I load this content's only when a click in the collapsible, and not load all in the beginning?

 

Hi Andrei,

As we have talked out list, it is possible to call the getContent client method in order to get data dinamically instead of using the zen mojo document stack. To do so, see the example code bellow:

ClientMethod onselect(key, value, docViewId) [ Language = javascript ]
{
console.log('select '+key);
var mainView zen(docViewId);
var realKey key.split(':')[0];
switch(realKey) {
case 'menu':
debugger;

zenPage.getContentProvider().invalidate('data','show-employee');
var obj {id:'103',level:value};
mainView.setDocumentKey('show-employee',obj);
mainView.getLayout().sourceData zenPage.getContent('data','show-employee',obj,1);
mainView.updateLayout();
break;
}
}

This example is going to manipulate de data document content on the document stack instead of adding a new document on the zen mojo document stack.

Also you can notice that the zen('mainView').currLevel will remains the same. It means that there is no new document inserted on the document stack after call getContent.

Zen Mojo is working with its all cache mechanism according to the document key which didn´t change. At this point when you call UpdateLayout Zen Mojo will just get the new document data (from getContent) and render the content (do the data binding) on the current document Layout.

Please, let me know if you have additional question about this topic.

P.S.: You can user 'force parameter' = 1 (zenPage.getContent('data','show-employee',obj,1); ) or call the invalidate (zenPage.getContentProvider().invalidate('data','show-employee'); ). According to the documentation the force parameter will clean the data before call the OnGetContent call back.

Regards.