I need to make sure certain essential data are loaded before a module is loaded and shown on screen. considering the async nature of data loading in silverlight, I was wondering if there is a pattern I should follow to load my data (like an event on the module or the bootstrap to hook into, or a method to override)...
you can set module InitializationMode to OnDemand and once you have your data call moduleManager.LoadModule("YourModuleName"); as described here.
There's another alternative as well. If you know you're going to need the module, and the data is statically stored inside another module, you can establish dependencies:
ModuleCatalog m = new ModuleCatalog();
...
m.AddModule(typeof(PersonModule.PersonModule), "ModuleA");
In this scenario, your module in question would establish a dependency on whatever module has the data, and this would ensure that the data is loaded before-hand.
Related
During debugging it can be very useful to ask a given module "ok, so what providers do you know about?" Since a module is essentially an inversion of control container which you explicitly register things (factories, values, controllers, etc) into it should absolutely be possible. I can't figure out how to do it though
If you call .requires on the module it should tell you what dependencies it has. I do this in my unit tests to monitor them and help prevent problems if one gets deleted somehow.
var appModule = angular.module('yourMod'),
deps = appModule.requires;
The value of deps will be an array containing the dependencies of the module.
For the other parts of Angular, I believe that you can call the .has() method of the injector and see if the dependency you want has been injected into the provider. Documentation: https://docs.angularjs.org/api/auto/service/$injector. This should be workable as most things deal with $injector.
I would like to be able to create a module as an interaction between sugarCRM and an other database. For that I built a module thanks to the module builder tool, and I would like to connect it to a new table which is a join between sugar data and my second app data (to prevent data duplication).
As my new table for the module is a view between two others, sugar views the content without any problem, but throws an exception whenever I try to insert anything. So I would like to use a logic hook who will directly store the data within the two "original" tables.
Here is my problem : even if the data are correctly stored, I would like to prevent sugar to try to store anything. Is there something I can do within my hook to stop sugar action, once my hook finished its job ?
Sorry for my terrible english and thanks for reading.
What I recommend is overriding the Save method in your custom module's controller.
Once you build and deploy the module, there will be a new directory: custom/modules/yourcustommodule. In that directory, create a file named controller.php.
That file should include the following (untested) code:
require_once('include/MVC/Controller/SugarController.php');
class yourcustommoduleController extends SugarController {
function action_save() {
return;
}
}
You could even move your before/after hooks into this custom action function. As long as you don't call the default save method (parent::action_save(); I think), SugarCRM's default save action(s) won't happen.
Important: after deploying a custom module, SugarCRM's best practice is to never redeploy it, but to make all subsequent changes in Studio. This is important because once you make these file-level changes to a custom module, those changes would be lost if you redeploy the module.
I am having difficulty in finding a relation between a given Module and Views(plain WPF user control) which has been Registered to different regions using this Module (in IModule Initialize() method).
When a Request comes to load a module IModuleManager.LoadModule is being used the first time to load the module. First time loading a module is not as issue.
Now, another request comes to load a module,which was already loaded so I can not use IModuleManager.LoadModule method, (User will just give ModuleName).
Now I have to find out what are the its Regions (need to clear them first) and its View (need to load them in there respective Regions).
So I need a map , kind of triplet, of Module-View-Region and create this triplet first time when IModuleManager.LoadModuleCompleted gets triggered. Later I can use this to find the regions and views.
Used IRegionViewRegistry.ContentRegistered but it just gives (Regions and Views). But no way to relate it to ModuleName(of Module Info) and IModuleManager.LoadModuleCompleted just gives ModuleInfo (no way to find out Regions and Views it uses)
Is there a function like unloadModel in cakePHP that should be called to unload a model that was loaded using loadModel() function?
I found an unload method,
http://api20.cakephp.org/file/Cake/Model/BehaviorCollection.php#method-BehaviorCollectionunload
But it seems to be used for Behavior. Im new to cake. Is there a function like that or does it get automatically unloaded when the called action loses scope?
One more doubt; is using loadModel against MVC's normal conventions? Does it have any adverse effects?
You do not need to unload your model. If you're going to use the model throughout the entire Controller, then use the $uses variable:
public $uses = array('MyModel', 'AnotherModel');
If you're going to just use it in a specific action(s), use loadModel:
$this->loadModel('MyModel');
That's it - no unloading necessary.
And no, it's not against MVC imo and I have seen no adverse effects.
It's VERY common to load a model. Example - most of my projects require a few "homepages" that have greatly-varying data from nearly ever model. In that case, I create a "DashboardsController", which doesn't even have a table - then I load each model when I need to access it's data. (Or with $uses if I'm going to use it's data in all the actions).
no, behaviors and models are two different things.
behaviors add functionality through hooks. Meaning: they alter the way other methods in models work. So if you want to geocode your data automatically, you use a geocoder behavior. Or if you want your results to be decrypted upon find, you add the decrypt behavior.
So there you NEED the option to detach/unload behaviors because you might not want this functionality there at some point.
Models are just access to the database or provide wrapper methods. They don't have to be removed in order for the rest of the site to function as they do not alter the way other methods work.
loadModel is just a way to dynamically load models that are not automatically related. its totally fine to do that from controller actions where you need those models.
Is this:
Web web = context.Web;
context.Load(web, w => w.Language);
context.ExecuteQuery();
or something similar in order to load web.Language with context.ExecuteQuery() possible in a silverlight client? The above code was taken from
http://www.dev4side.com/community/blog/2011/1/5/incorrect-dates-taken-from-sharepoint-2010-client-object-model.aspx
When I do so, instantiating the web's Language property always yields
Microsoft.SharePoint.Client.PropertyOrFieldNotInitializedException
Btw, this code is in an extra thread (not the UI thread). I know that there is context.loadQueryAsync() but I already have an extra thread and would like to keep things together.
As far as I've tried this code works ok. Do you maybe access some other properties of the Web object that are not loaded? You'd have to include them also in your load method.