Hi i have a little question about module initializations.
I have a module called NewsModule for displaying... news !
So this module needs an UserId used to retrieve user associated news from a WCF webservice.
My question : How and what is the best practice to inform my NewsModule that it will display news of a specific UserId ?
Thanks by advance
I currently have a solution that includes a set of Prism projects and a web project. The web project hosts a login page, the containing page for my Prism shell, and the WCF services used to deliver data to the Silverlight modules. These services can
use the same session object established by the login action, so the job of determining which data to return belongs to the service, which to me is as it should be.
Use something like HttpContext.Current.Session["UserId"] (which was created at login) to inform your queries and you are good to go.
I have not yet used a multi-targeted module to access my services (from a WPF app, for example) so I am not sure what devils lie in the details of identifying a user who did not login on the same web service where the WCF services are hosted, but if you
are Silverlight-in-browser-at-a-specific-URL, this scenario is architecturally sound and simple (in my humble opinion).
If I understand your scenario correctly, you have a
NewsModule, which probably has a NewsView (or something of the sort), with its Presenter (could also be ViewModel orController).
As I picture it, the Presenter could perform the request to the WCF service getting the
UserID from someone.
I do not know your exact scenario, but you could get the
UserID in different ways.
For example, if you have a single
NewsView which only shows news related to the logged in user, you could get the ID from your Login/Authentication Service (if you have it).
Another example can be seen in the
Prism-v2 StockTrader Reference Implementation solution that
comes with the Guidance. You can check the NewsModule in it. The implementation in the RI shows news based on the selected item of a ListView.
Please let me know if this helps.
i use regular module initialize model to load on demand modules, but i'm facing to a problem :
When my app is launched, this one ask a username et password, i call a web service to retrieve user informations.
So i display a module that load on demand 6 modules (and one of it is NewsModule) the main module represent an user dashboard. So in module news i don't know the user id when this one become loaded.
Generaly in CAL samples modules simply load static data in xml file, etc.
In my case in NewsModule i need to be informed that this one needs to load news data with distant access with a specific Id.
So my question is what the best practice to access to this from NewsModule
NewsModule is also used for display friend dashboard...
Actualy i do that (but i'm not happy of it):
In main module container:
Container.RegisterType<User>("ConnectedUser", new ContainerControlledLifetimeManager());
User u = Container.Resolve<User>("ConnectedUser");
u.FirstName = "Toto";
u.LastName = "Tata";
And in child module :
public class NewsModule : IModule
private readonly IRegionManager _regionManager;
private readonly IUnityContainer _container;
private readonly IEventAggregator _eventAggregator;
public NewsModule (IRegionManager regionManager, IUnityContainer container, IEventAggregator eventAggregator)
_container = container;
_eventAggregator = eventAggregator;
_regionManager = regionManager;
#region IModule Members
public void Initialize()
NewsListViewViewModel vm = _container.Resolve<NewsListViewViewModel>();
NewsListView view = _container.Resolve<NewsListView>();
view.DataContext = vm;
User u = _container.Resolve<User>("ConnectedUser");
So i think that it's not that you specify but i don't understand how inject an instance of my user object in my NewsModule