Topic
  • 6 replies
  • Latest Post - ‏2012-10-05T10:45:19Z by HSSH_Sandip_Kulkarni
HSSH_Sandip_Kulkarni
13 Posts

Pinned topic Events and Model Comunication

‏2012-09-26T13:53:42Z |
I have a model m1 from which I intend to fire an event to model m2. M2 should receive the event and render/process page1 from m2 model.
Dont want to import m2 model in m1 as model container or similar.
What is the best way to do so. Attached are sample m1 and m2 models. This is for a standalone web application
Updated on 2012-10-05T10:45:19Z at 2012-10-05T10:45:19Z by HSSH_Sandip_Kulkarni
  • mburati
    mburati
    352 Posts

    Re: Events and Model Comunication

    ‏2012-09-26T14:11:09Z  
    It's usually best to have a single controller model (even standalone) and not bounce around from one model to another directly from the browser (especially if you might ever want to use the standalone model as a portlet someday), so something like Model Container would be the typical recommendation afaik.

    That said, if you absolutely have to (and it's only ever going to be standalone), the WEF URLMapper API includes a method to return a URL to a specified "model" and action (as opposed to just action) which can allow you to switch to another controller model (again, standalone only, not really useful for portlets which have a single controller model per portlet) and execute an action in that other model directly from a control on the page in the first model.

    Note, if you're building standalone (non-portal) WEF apps, the licensing for standalone WEF may be different than the portal WEF runtime licensing, so be sure to check with your sales/support contact to be sure you're licensed for that usage. As always, use an official and appropriate IBM contact for licensing guidance, not info posted on a public forum like this.

    I hope that info helps,
    ..mb1
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • HSSH_Sandip_Kulkarni
    13 Posts

    Re: Events and Model Comunication

    ‏2012-10-01T12:51:39Z  
    • mburati
    • ‏2012-09-26T14:11:09Z
    It's usually best to have a single controller model (even standalone) and not bounce around from one model to another directly from the browser (especially if you might ever want to use the standalone model as a portlet someday), so something like Model Container would be the typical recommendation afaik.

    That said, if you absolutely have to (and it's only ever going to be standalone), the WEF URLMapper API includes a method to return a URL to a specified "model" and action (as opposed to just action) which can allow you to switch to another controller model (again, standalone only, not really useful for portlets which have a single controller model per portlet) and execute an action in that other model directly from a control on the page in the first model.

    Note, if you're building standalone (non-portal) WEF apps, the licensing for standalone WEF may be different than the portal WEF runtime licensing, so be sure to check with your sales/support contact to be sure you're licensed for that usage. As always, use an official and appropriate IBM contact for licensing guidance, not info posted on a public forum like this.

    I hope that info helps,
    ..mb1
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    I have a web application whose home page has 2 sections
    • section has all menu contents and section 2 has to display the data ( from different models) based on the menu selected item

    Now, the only way I seem to be able to do this is
    • have the section 2 as a model container initially loading an empty model.
    • then based on the menu item selected, call ModelContainername.setModelName("<modeltobeloaded")
    • So for each menu selection, I would be calling and changing the model to be loaded in section 2.

    I am not sure if this is the best way.

    Hence, I wanted to call the events in a way that the called model which houses the event handler to load and display the page contents can render the page directly in the designated page area of the homepage in section 2.
  • mburati
    mburati
    352 Posts

    Re: Events and Model Comunication

    ‏2012-10-01T17:49:28Z  
    I have a web application whose home page has 2 sections
    • section has all menu contents and section 2 has to display the data ( from different models) based on the menu selected item

    Now, the only way I seem to be able to do this is
    • have the section 2 as a model container initially loading an empty model.
    • then based on the menu item selected, call ModelContainername.setModelName("<modeltobeloaded")
    • So for each menu selection, I would be calling and changing the model to be loaded in section 2.

    I am not sure if this is the best way.

    Hence, I wanted to call the events in a way that the called model which houses the event handler to load and display the page contents can render the page directly in the designated page area of the homepage in section 2.
    The best practices documentation on the Web Experience Factory wiki states that it's best to use a single model per model container, and to use multiple model containers and switch between them if you need to, rather than switching the model that's in a single model container slot.
    http://www-10.lotus.com/ldd/pfwiki.nsf/dx/06292009042040PMWEBRV3.htm
    and
    http://www3.software.ibm.com/ibmdl/pub/software/dw/wes/pdf/0606_odonnell-WPF-BestPractices.pdf

    Depending on what you need to use for menu navigation, you may want to take a look at the Tab builders (Dojo Tab Container, Page Tabs) to help automate switching sub-pages, placing a model container on each tabbed page.
    http://www-10.lotus.com/ldd/pfwiki.nsf/dx/Building_Tab_Layouts_with_IBM_Web_Experience_Factory

    I hope that info helps,
    ..mb1
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • HSSH_Sandip_Kulkarni
    13 Posts

    Re: Events and Model Comunication

    ‏2012-10-03T06:09:21Z  
    • mburati
    • ‏2012-10-01T17:49:28Z
    The best practices documentation on the Web Experience Factory wiki states that it's best to use a single model per model container, and to use multiple model containers and switch between them if you need to, rather than switching the model that's in a single model container slot.
    http://www-10.lotus.com/ldd/pfwiki.nsf/dx/06292009042040PMWEBRV3.htm
    and
    http://www3.software.ibm.com/ibmdl/pub/software/dw/wes/pdf/0606_odonnell-WPF-BestPractices.pdf

    Depending on what you need to use for menu navigation, you may want to take a look at the Tab builders (Dojo Tab Container, Page Tabs) to help automate switching sub-pages, placing a model container on each tabbed page.
    http://www-10.lotus.com/ldd/pfwiki.nsf/dx/Building_Tab_Layouts_with_IBM_Web_Experience_Factory

    I hope that info helps,
    ..mb1
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    I understand the best practices and have gone thru the sample model available at http://www-10.lotus.com/ldd/pfwiki.nsf/dx/07292008112740AMWEBL5U.htm

    But even here if you want to navigate between different pages across models, all those models need to be a part of main base model as model containers.

    So we I have 50 menu items and each of of them needs to load a particular model. I would require to have all these 50 models as model containers in my base controller model. I believe this would have a performance impact. hence to avoid the same, I am using one model container and swapping in / out models in the same using ModelContainer.setModelname API.

    If there something that I am missing here or better my approach.
  • mburati
    mburati
    352 Posts

    Re: Events and Model Comunication

    ‏2012-10-03T14:00:55Z  
    I understand the best practices and have gone thru the sample model available at http://www-10.lotus.com/ldd/pfwiki.nsf/dx/07292008112740AMWEBL5U.htm

    But even here if you want to navigate between different pages across models, all those models need to be a part of main base model as model containers.

    So we I have 50 menu items and each of of them needs to load a particular model. I would require to have all these 50 models as model containers in my base controller model. I believe this would have a performance impact. hence to avoid the same, I am using one model container and swapping in / out models in the same using ModelContainer.setModelname API.

    If there something that I am missing here or better my approach.
    If you have too many models and/or unknown models to pre-load into containers, and you need to swap them in dynamically based on menu choice, then I suggest at least being careful that you understand the semantics of what's loaded and what's not, to avoid things like URLs in the outer container pointing to an action in a contained model that's no longer loaded etc.

    Going back to your question about this a couple posts ago, it seems like you would need to set the contained model into the container first and then fire the event for it to do its thing and then go to the right page (unless its default page is good enough) since you can't just fire the event if the contained model isn't yet loaded, since it wouldn't be there to listen for that event yet.

    I hope that info helps,
    ..mb1
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • HSSH_Sandip_Kulkarni
    13 Posts

    Re: Events and Model Comunication

    ‏2012-10-05T10:45:19Z  
    • mburati
    • ‏2012-10-03T14:00:55Z
    If you have too many models and/or unknown models to pre-load into containers, and you need to swap them in dynamically based on menu choice, then I suggest at least being careful that you understand the semantics of what's loaded and what's not, to avoid things like URLs in the outer container pointing to an action in a contained model that's no longer loaded etc.

    Going back to your question about this a couple posts ago, it seems like you would need to set the contained model into the container first and then fire the event for it to do its thing and then go to the right page (unless its default page is good enough) since you can't just fire the event if the contained model isn't yet loaded, since it wouldn't be there to listen for that event yet.

    I hope that info helps,
    ..mb1
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    Firing of events will not happen between different main models that are being loaded in the model container or from the menu to to any of the models.

    Firing of events will happen only with model containers that are added to the main base models (with main action) loaded in the base model container (the one page with menu in one section and model container in other section).

    If I understand correctly, the only way to load multiple models in a specified section of a page or container is to swap the models using setModelName API

    Each model that is loaded will call its main action and display a page.

    While doing this I realised that the session data held by each model loading in the container is not flushed out when I swap models. I know this is expected but is there a way to clear that data when a different model is loaded in the same model container.