IC5Notice: We have upgraded developerWorks Community to the latest version of IBM Connections. For more information, read our upgrade FAQ.
Topic
  • 40 replies
  • Latest Post - ‏2013-03-01T17:22:52Z by CarlD
XWHK_Joe_DeLutis
XWHK_Joe_DeLutis
80 Posts

Pinned topic Model Container

‏2013-01-04T21:11:09Z |
Went out to http://www-10.lotus.com/ldd/pfwiki.nsf/dx/07292008112740AMWEBL5U.htm (Community Articles > Web Experience Factory > Samples and Techniques for Web Experience Factory > Techniques for building a controller model using Model Container and events) to read up on using Model Containers for performance. I downloaded the package (code sample) and do not understand why when I click on the Order ID link in the View One Page that it only works on the first press of the linked Order ID. Whenever I go to another row after the first pass it appears the Assignment!Variables/SelectedItemID=${Arguments/orderID} does not get loaded with the current Order ID row value. Can someone help me understand why this is happening?
Updated on 2013-03-01T17:22:52Z at 2013-03-01T17:22:52Z by CarlD
  • XWHK_Joe_DeLutis
    XWHK_Joe_DeLutis
    80 Posts

    Re: Model Container

    ‏2013-01-07T17:37:38Z  
    Can someone explain why the RowLoopVar does not change in this sample (see URL from previous post)?
  • SystemAdmin
    SystemAdmin
    9029 Posts

    Re: Model Container

    ‏2013-01-07T18:33:39Z  
    Can someone explain why the RowLoopVar does not change in this sample (see URL from previous post)?
    The row loop var works fine for me running on a standalone J2EE container (not Portal). Do you have errors in the log file? Do you have the Tutorials and Samples feature set enabled for the project?

    However, I had to disable WEF's Partial Page Refresh by adding a Theme builder in Main.model and setting the two inputs under the Partial-Page Refresh section to No. I don't know off the top of my head how to alter the app so partial page refresh would work.

    --Sam
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • SystemAdmin
    SystemAdmin
    9029 Posts

    Re: Model Container

    ‏2013-01-07T18:42:52Z  
    The row loop var works fine for me running on a standalone J2EE container (not Portal). Do you have errors in the log file? Do you have the Tutorials and Samples feature set enabled for the project?

    However, I had to disable WEF's Partial Page Refresh by adding a Theme builder in Main.model and setting the two inputs under the Partial-Page Refresh section to No. I don't know off the top of my head how to alter the app so partial page refresh would work.

    --Sam
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    Again, the loop var is fine for me. Let us know if you see errors.

    I figured out the partial page refresh issue: The WEF code that implements partial page refreshing gets added to the page twice, once in view1.model and again in view2.model. This causes a conflict. In one of the models -- say, view2.model -- add a Theme builder and disable Partial Page Refreshing.

    Then it will work fine with partial page refreshing.

    --Sam
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • XWHK_Joe_DeLutis
    XWHK_Joe_DeLutis
    80 Posts

    Re: Model Container

    ‏2013-01-07T19:16:47Z  
    Again, the loop var is fine for me. Let us know if you see errors.

    I figured out the partial page refresh issue: The WEF code that implements partial page refreshing gets added to the page twice, once in view1.model and again in view2.model. This causes a conflict. In one of the models -- say, view2.model -- add a Theme builder and disable Partial Page Refreshing.

    Then it will work fine with partial page refreshing.

    --Sam
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    Can you please post your models? I still have not been able to get this to work. It seems that for efficiency we should implement Model Containers, so I need to understand this sample in order to apply it to a real Portal Application that I will need to develop.
  • XWHK_Joe_DeLutis
    XWHK_Joe_DeLutis
    80 Posts

    Re: Model Container

    ‏2013-01-07T19:34:52Z  
    Can you please post your models? I still have not been able to get this to work. It seems that for efficiency we should implement Model Containers, so I need to understand this sample in order to apply it to a real Portal Application that I will need to develop.
    No errors in the logs. I have the Tutorials/Samples on. When the Main Page comes up I see 2 views. When I select a hyperlink (Order ID) from view 1 I go to the details page and it displays the proper Order ID. When I return to the Main Page and select another order id on View 1 to go to details page, the original Order ID that I first selected continually appears. Also, when I select an order id from view 2 nothing happens. The "update' form does not display.
  • SystemAdmin
    SystemAdmin
    9029 Posts

    Re: Model Container

    ‏2013-01-07T20:34:43Z  
    No errors in the logs. I have the Tutorials/Samples on. When the Main Page comes up I see 2 views. When I select a hyperlink (Order ID) from view 1 I go to the details page and it displays the proper Order ID. When I return to the Main Page and select another order id on View 1 to go to details page, the original Order ID that I first selected continually appears. Also, when I select an order id from view 2 nothing happens. The "update' form does not display.
    I see what you mean, and I can reproduce it. (I misread your earlier post)

    Unfortunately, the sample application has a blatant bug; the original author did it wrong. The Loop Var is working correctly -- the order id of the current row is passed in the event, which can easily be seen when you SystemOut it -- but the Detail1 and Detail2 model don't know to re-execute the service using the new id.

    Give me a day to fix it.

    --Sam
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • XWHK_Joe_DeLutis
    XWHK_Joe_DeLutis
    80 Posts

    Re: Model Container

    ‏2013-01-07T21:19:18Z  
    I see what you mean, and I can reproduce it. (I misread your earlier post)

    Unfortunately, the sample application has a blatant bug; the original author did it wrong. The Loop Var is working correctly -- the order id of the current row is passed in the event, which can easily be seen when you SystemOut it -- but the Detail1 and Detail2 model don't know to re-execute the service using the new id.

    Give me a day to fix it.

    --Sam
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    Thanks...I'll keep a watch out for whatever you can provide to me.
  • SystemAdmin
    SystemAdmin
    9029 Posts

    Re: Model Container

    ‏2013-01-10T20:21:32Z  
    Thanks...I'll keep a watch out for whatever you can provide to me.
    I apologize for the delay.

    I quickly put together a more simplistic sample and article.

    See http://www-10.lotus.com/ldd/pfwiki.nsf/dx/Componentizing_your_UI_with_the_Model_Container_and_Event_Builders

    Let me know if you have questions.

    --Sam
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • XWHK_Joe_DeLutis
    XWHK_Joe_DeLutis
    80 Posts

    Re: Model Container

    ‏2013-01-10T20:56:19Z  
    I apologize for the delay.

    I quickly put together a more simplistic sample and article.

    See http://www-10.lotus.com/ldd/pfwiki.nsf/dx/Componentizing_your_UI_with_the_Model_Container_and_Event_Builders

    Let me know if you have questions.

    --Sam
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    Sam,

    Example is helpful but I am looking for something a little more detailed. I have an application that starts with a Main Menu with a few radio buttons on it. Based on what I select I go to a "leg" of the application that allows me to view all orders (view and form). That Orders view and form has a button on it that allows me to add a new order (open an input form). I can also select an existing order from the list to update it. The other options off the Main Menu are to view reports on orders. Can you show me how to add a "main menu" that calls out to the Main.model in your example and then allows your Main.Model to return to a "main menu"? My goal is to build a parent-child model framework where the parent is a main menu and all other functions are children from the main menu.

    Thanks,
    JD
  • SystemAdmin
    SystemAdmin
    9029 Posts

    Re: Model Container

    ‏2013-01-10T22:06:22Z  
    Sam,

    Example is helpful but I am looking for something a little more detailed. I have an application that starts with a Main Menu with a few radio buttons on it. Based on what I select I go to a "leg" of the application that allows me to view all orders (view and form). That Orders view and form has a button on it that allows me to add a new order (open an input form). I can also select an existing order from the list to update it. The other options off the Main Menu are to view reports on orders. Can you show me how to add a "main menu" that calls out to the Main.model in your example and then allows your Main.Model to return to a "main menu"? My goal is to build a parent-child model framework where the parent is a main menu and all other functions are children from the main menu.

    Thanks,
    JD
    Common pattern, ive done something similar before for customer. Not by computer at moment, but I'll see what I can do. Basically same concept: model container and events.

    --SamThe postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • SystemAdmin
    SystemAdmin
    9029 Posts

    Re: Model Container

    ‏2013-01-11T21:19:26Z  
    Common pattern, ive done something similar before for customer. Not by computer at moment, but I'll see what I can do. Basically same concept: model container and events.

    --SamThe postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    See this article and sample app I just put together. http://www-10.lotus.com/ldd/pfwiki.nsf/dx/Building_a_Componentizedcom_Menu-driven_Application_with_Model_Container

    It uses WEF's Page Navigation builder and the Model Container builder together to achieve the functionality you're looking for.

    Hope this helps.

    --Sam
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • SystemAdmin
    SystemAdmin
    9029 Posts

    Re: Model Container

    ‏2013-01-15T15:43:51Z  
    See this article and sample app I just put together. http://www-10.lotus.com/ldd/pfwiki.nsf/dx/Building_a_Componentizedcom_Menu-driven_Application_with_Model_Container

    It uses WEF's Page Navigation builder and the Model Container builder together to achieve the functionality you're looking for.

    Hope this helps.

    --Sam
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    JD,
    Feedback?
    Thanks,
    Sam
  • XWHK_Joe_DeLutis
    XWHK_Joe_DeLutis
    80 Posts

    Re: Model Container

    ‏2013-01-15T16:10:16Z  
    JD,
    Feedback?
    Thanks,
    Sam
    Sam,

    Still going through things. Have started to apply the principles to a real prototype. So far the example has been very helpful. I take it I could use a page with radio buttons in the Main Model as opposed to a page with page navigation builder, correct? I reply back with more info when I get through more of my prototype, but so far what you posted has been really helpful.

    JD
  • XWHK_Joe_DeLutis
    XWHK_Joe_DeLutis
    80 Posts

    Re: Model Container

    ‏2013-01-15T18:18:18Z  
    Sam,

    Still going through things. Have started to apply the principles to a real prototype. So far the example has been very helpful. I take it I could use a page with radio buttons in the Main Model as opposed to a page with page navigation builder, correct? I reply back with more info when I get through more of my prototype, but so far what you posted has been really helpful.

    JD
    One final question for you Sam.... if I wanted the to be able to pass keys/values to and from the models being "swapped" in and out, could I do this using "shared variables"? I am assuming I could do so.
  • SystemAdmin
    SystemAdmin
    9029 Posts

    Re: Model Container

    ‏2013-01-15T18:25:04Z  
    One final question for you Sam.... if I wanted the to be able to pass keys/values to and from the models being "swapped" in and out, could I do this using "shared variables"? I am assuming I could do so.
    Shared Variable would work, but you can also pass values using the Event Declaration and Event Handler builders. In Event Declaration, you can define what data you want to pass to the handlers. When you fire the event, Designer will prompt you for the data to pass in the event. In the Event Declaration builder, when you select an event to handle, it will recognize the data and you can do what you want with it. Eventing seems like the preferred way here.
    --Sam
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • SystemAdmin
    SystemAdmin
    9029 Posts

    Re: Model Container

    ‏2013-01-15T19:05:47Z  
    Sam,

    Still going through things. Have started to apply the principles to a real prototype. So far the example has been very helpful. I take it I could use a page with radio buttons in the Main Model as opposed to a page with page navigation builder, correct? I reply back with more info when I get through more of my prototype, but so far what you posted has been really helpful.

    JD
    And to answer your question about having radio buttons instead: It comes out of the box with several examples of Page Navigation templates; my example used the Multi-Line Navigation List. The Page Navigation builder was intentionally designed to so that you can create your own "template" for creating the Navigation Menu. I just created my own template to use with Page Navigation using the html fragment below and got it to display radio buttons instead. When you click a radio button, the corresponding application loads, just like with the original sample.

    The Page Navigation builder uses Data Layout builder under the covers. Thus, if you want to create your own template like I've done, then take a look at the builder help for Data Layout builder. It describes the location where you put your template so that you can select it at design time in the Page Navigation or Data Layout builder, the WEF-specific tags (such as data-repeat-wrapper, data-target, etc) that page automation uses to creating the repeating elements in your menu, and the "meta" element at the top of the template.

    Note that I'm dubious as to whether the choice of radio buttons is prudent, considering all the great UI styling you can do these days. I'd recommend having a good UX or Front End developer create a navigation ui for you, then turn it in to a Page Navigation/Data Layout template as described.

    
    <meta data-template-id=
    "NavigationList" data-template-type=
    "navigation" data-template-bundle-name=
    "com.bowstreet.builders.webapp.package" data-template-name-id=
    "DataLayoutNavigationListName" data-template-description-id=
    "DataLayoutNavigationListDescription" data-template-name=
    "Navigation List" data-template-description=
    "This template allows you to generate a simple navigation list." data-stylesheets=
    "/factory/data_layout_templates/navigation_list.css,/factory/data_layout_templates/blank.css" />   <div data-repeat-wrapper=
    "default"> <div data-repeat-wrapper=
    "Item"> <input type=
    "radio" name=
    "group1" value=
    "test" /> <label for=
    "group1"><span data-target=
    "name"></span> </label> <br/> </div> </div>
    


    --Sam
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • XWHK_Joe_DeLutis
    XWHK_Joe_DeLutis
    80 Posts

    Re: Model Container

    ‏2013-01-16T16:48:26Z  
    Shared Variable would work, but you can also pass values using the Event Declaration and Event Handler builders. In Event Declaration, you can define what data you want to pass to the handlers. When you fire the event, Designer will prompt you for the data to pass in the event. In the Event Declaration builder, when you select an event to handle, it will recognize the data and you can do what you want with it. Eventing seems like the preferred way here.
    --Sam
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    Sam,

    I have 3 models swapping in and out. When I am in "model 1" on a view form and press a button that "fires" an event being handled in "model 2" nothing happens. I have an event handler in model 2 that is to use a passed value to read the database. Model 2 never gets fired. Can you help? I need to pass data between the models being swapped in and out of the container. Do I need to fire the vent and swap model 2 into the container for this to occur?

    JD
  • SystemAdmin
    SystemAdmin
    9029 Posts

    Re: Model Container

    ‏2013-01-16T18:46:45Z  
    Sam,

    I have 3 models swapping in and out. When I am in "model 1" on a view form and press a button that "fires" an event being handled in "model 2" nothing happens. I have an event handler in model 2 that is to use a passed value to read the database. Model 2 never gets fired. Can you help? I need to pass data between the models being swapped in and out of the container. Do I need to fire the vent and swap model 2 into the container for this to occur?

    JD
    Sounds like Model 2 is not loaded. Swapping in model 2 into container is one way to load it.

    --Sam
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • XWHK_Joe_DeLutis
    XWHK_Joe_DeLutis
    80 Posts

    Re: Model Container

    ‏2013-01-16T18:49:43Z  
    Sounds like Model 2 is not loaded. Swapping in model 2 into container is one way to load it.

    --Sam
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    Not sure how to swap the model in when the button in model 1 is pressed. Would it help if I posted the models for you to look at and give me advise?
  • CarlD
    CarlD
    46 Posts

    Re: Model Container

    ‏2013-01-16T19:31:38Z  
    Sam,

    I have 3 models swapping in and out. When I am in "model 1" on a view form and press a button that "fires" an event being handled in "model 2" nothing happens. I have an event handler in model 2 that is to use a passed value to read the database. Model 2 never gets fired. Can you help? I need to pass data between the models being swapped in and out of the container. Do I need to fire the vent and swap model 2 into the container for this to occur?

    JD
    You may want to also check out a similar article I wrote on this topic a while ago. This sure seems like a great design pattern for WEF.

    http://www-10.lotus.com/ldd/pfwiki.nsf/dx/Leveraging_the_Model_Container_Builder

    There is a download link at the bottom of the article with a runnable model.

    Hope that helps.
    Carl.


    IBM Certified Solution Developer - WebSphere Portlet Factory 7.0
    My blog http://dsixe-wpf.blogspot.com
  • XWHK_Joe_DeLutis
    XWHK_Joe_DeLutis
    80 Posts

    Re: Model Container

    ‏2013-01-17T21:55:05Z  
    • CarlD
    • ‏2013-01-16T19:31:38Z
    You may want to also check out a similar article I wrote on this topic a while ago. This sure seems like a great design pattern for WEF.

    http://www-10.lotus.com/ldd/pfwiki.nsf/dx/Leveraging_the_Model_Container_Builder

    There is a download link at the bottom of the article with a runnable model.

    Hope that helps.
    Carl.


    IBM Certified Solution Developer - WebSphere Portlet Factory 7.0
    My blog http://dsixe-wpf.blogspot.com
    Carl,
    One question...how do you pass multiple parameters when using the ModelInitializationData?
    JD
  • CarlD
    CarlD
    46 Posts

    Re: Model Container

    ‏2013-01-17T22:19:27Z  
    Carl,
    One question...how do you pass multiple parameters when using the ModelInitializationData?
    JD
    Since ModelInitializationData is a single parameter, multiple values would have to be packaged as xml before being sent in the event, and unpackaged when received in the child model.

    Carl.


    IBM Certified Solution Developer - WebSphere Portlet Factory 7.0
    My blog http://dsixe-wpf.blogspot.com
  • XWHK_Joe_DeLutis
    XWHK_Joe_DeLutis
    80 Posts

    Re: Model Container

    ‏2013-01-21T18:00:17Z  
    • CarlD
    • ‏2013-01-17T22:19:27Z
    Since ModelInitializationData is a single parameter, multiple values would have to be packaged as xml before being sent in the event, and unpackaged when received in the child model.

    Carl.


    IBM Certified Solution Developer - WebSphere Portlet Factory 7.0
    My blog http://dsixe-wpf.blogspot.com
    Carl,

    Love the example but how do you handle database errors? For instance, I have a model loaded into the container that inserts data into Oracle. I created an event handler to address database errors but I cannot redisplay the current page with an error message. Can you supply database error handling suggestions/examples for me?

    JD
  • XWHK_Joe_DeLutis
    XWHK_Joe_DeLutis
    80 Posts

    Re: Model Container

    ‏2013-01-21T18:42:56Z  
    Carl,

    Love the example but how do you handle database errors? For instance, I have a model loaded into the container that inserts data into Oracle. I created an event handler to address database errors but I cannot redisplay the current page with an error message. Can you supply database error handling suggestions/examples for me?

    JD
    DISREGARD last message. I think I have created a solution!