Sub-WAP Business Modules and Child Business Modules?

Oct 17, 2008 at 2:04 PM

I am creating a web application that will have two significantly complex business modules, both of which I imagine will be comprised of other (child) business modules.  I created the two complex modules as sub-Web Application Projects business modules.  I expected that when I created a new business module after that point I would have the option of selecting one of the sub-WAP business modules as the host for the new business module's web pages, but that's not the case.

Is there a way to create a business module the web pages of which exist within another sub-WAP-based business module?  Or, is this not how the sub-WAP functionality is intended to be used?

Thanks.

Oct 17, 2008 at 7:28 PM

Hi

 

When you create your Business Module as a sub-Web Application Project, the project is created as a folder of the root web project. To be able to have the option of selecting one of the sub-WAP Business Modules as the host for the new Business Module's Web Pages you could perform the following steps:

 

1.       Unload your WAP Business Module right-clicking over the project and selecting Unload Project option.

2.       Edit the project file (.csproj  or .vbproj). To do this right click in the unloaded project and select Edit YourModule.Web option.

3.       Remove the IsFolderOfRootWebProject attribute from the UserProperties tag. The resulting tag should look like the following one:

<UserProperties IsWebProject="true" />

4.       Reload the project right-clicking over the unloaded project and selecting Reload Project option.

 

Now you will be able to select your sub-WAP Business Module as the host for your new Business Modules.

 

Take into account that the virtual path of your WAP Business Module will be ~/YourWAPBusinessModule/. So when you host a Business Module inside it, you should change the virtualpath attribute in the Web.config and the URL of the module’s pages in the site map. To do this perform the following steps:

1.       Open the Web.config file located in the folder of the hosted Business Module inside your WAP Business Module.

2.       Inside the Configuration/compositeWeb/modules node change the virtualPath attribute in the module tag. The resulting tag should look like the following:

<module name="HostedBusinessModule" assemblyName="HostedBusinessModule" virtualPath="~/YourWAPBusinessModule/HostedBusinessModule">

<dependencies>

<dependency module="Shell" />

</dependencies>

</module>

3.       In the ModuleInitializer class of the hosted Business Module modify the URL of all its web pages with the new virtual path. The ending RegisterSiteMapInformation method should look like the following one:

protected virtual void RegisterSiteMapInformation(ISiteMapBuilderService siteMapBuilderService)

{

SiteMapNodeInfo moduleNode = new SiteMapNodeInfo("HostedBusinessModule", "~/YourWAPBusinessModule/HostedBusinessModule/Default.aspx", "HostedBusinessModule");

siteMapBuilderService.AddNode(moduleNode);

 

// TODO: register other site map nodes that HostedBusinessModule module might provide           

}

 

Perhaps you could find useful the following thread that deals with a similar question but using Web Sites instead of Web Application Projects:

·         Create another website inside same wcsf solution

 

Please let me know if this helps.

 

Mariano Converti

http://blogs.southworks.net/mconverti
Oct 19, 2008 at 6:47 PM
Thanks for the reply, Mariano!

I am noticing a shortcoming of trying this.  After I have created the sub-Web Application Project business module and have followed these steps, I get the following error from Visual Studio when I try to use the "Add User Control" recipe on the sub-Web Application Project:

Microsoft.Practices.WizardFramework.WizardExecutionException: The wizard  failed to execute. The error was:
Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Practices.WebClientFactory.CustomWizardPages.CreateViewPageBaseModel.FilterProjectsWithVirtualPathNotNullAndContainedInCurrentWebsite(List`1 moduleProjects, DependantModuleInfo[] moduleInfos, IList`1 webFolders)
   at Microsoft.Practices.WebClientFactory.CustomWizardPages.CreateViewPageBaseModel.get_ModuleProjects()
   at Microsoft.Practices.WebClientFactory.CustomWizardPages.CreateViewPageBasePresenter.OnViewReady()
   at Microsoft.Practices.WebClientFactory.CustomWizardPages.CreateViewPageBase.InitializePresenterAndModel()
   at Microsoft.Practices.WebClientFactory.CustomWizardPages.CreateViewPageBase.OnLoad(EventArgs e)
   ....

The error seems like it's only related to the wizard/recipe, and hopefully there's no issues with the software factory framework in doing all of this.
Oct 20, 2008 at 9:32 PM

Hi,

 

As a workaround for your requirement, you should  change the value of the property IsFolderOfRootWebProject attribute instead of deleting it:

·         When you want to add child Business Modules to the sub-WAP Business Module: You should set the IsFolderOfRootWebProject=”false”.

·         When you want to work with the child Business Modules, for example: adding Views, Users controls, etc.: You should set the IsFolderOfRootWebProject=”true”.

 

Please, let me know if you find this useful.

 

Ezequiel Sculli

http://blogs.southworks.net/esculli/