7 Replies Latest reply on Aug 7, 2007 8:48 PM by Igor Shabalov

    master-detail example

    Kevin Taylor Newbie

      I am really struggling with this concept. Basically, I would like to present the user with a datagrid (master) that will initially present a number of rows in the database. When the user clicks on a link I would like the information to present in a modal panel, with the option to display any number of pages in a wizard-like format. Now here is the problem, I need to be able to populate the fields with their proper values from the database. In this scenario, an action will not always work. I need a way to populate the form when the page is initially loaded. The only place I can see doing this from the backing bean is in the constructor, but it is hard to believe that there is no other place. Any suggestions would be greatly appreciated.

        • 1. Re: master-detail example
          Igor Shabalov Apprentice

          It is hard to understand you usecase. Why do you have problem with action? Why it does not work? What form do you need to populate?

          Did you try use of a4j:actionParam? I guess all you need is a4j:commandLink that will call the action, re-render some rich:modalpanel and than activate it using oncomplete.

          • 2. Re: master-detail example
            Kevin Taylor Newbie

            Lets look at a wizard scenario, mutliple pages. The data for the first page will be loaded from the action .. this part is ok. The problem for me comes after the first page. How do I save the data for the previous page and also call an action to get data for the second page and subsequent pages? It seems as if I can only do one or the other but not both.

            • 3. Re: master-detail example
              Igor Shabalov Apprentice

              a4j:include is best used for exactly such scenario. You may have almost regular page flow, but inside of the model popup on single page. All you need to do is to use a4j:commandButtons/a4j:commandlink with actions that return navigation cases.

              • 4. Re: master-detail example
                Kevin Taylor Newbie

                its not so much the navigation that is my problem as it is the population of the bean bound to the subsequent pages. Where should the bean population occur? In the constructor or is there another way to handle this? For example, after someone saves page 1 and is redirected to page 2, a save is needed for the data entered or modified on page 1 and the bean for page 2 needs to be populated as well. Where in this scenario should the population occur?

                • 5. Re: master-detail example
                  Igor Shabalov Apprentice

                  Are you using seam?

                  If yes, you need to start new conversation when you activate popup (in action code) and this must load all data to conversation scope. If not, you need to put it into session or use a4j:keepAlive. In any case you must load data (ether all or some key value in event that activate popup. Later you can have additional load on actions behind "next" "prev" buttons on your wizard popup.

                  • 6. Re: master-detail example
                    Kevin Taylor Newbie

                    I am not using seam. I have several smaller backing beans that could really grow in memory usage if I have to lump them together into one. Unless I am reading this wrong, it seems as if you are suggesting that I use one bean for all of the pages in the wizard and that I populate the fields at the point that the user clicks the link to view or edit a particular record and then use the keepalive for it to persist across the different requests. There are several concerns I have about this approach. For one, this seems as if it will put alot of extra information into memory that will not necessarily be needed until that part of the wizard is reached. Also, the pages range to simple data entry to more complex business rules. This approach also seems as if it will add to the complexity of the application. Is there a way to load only the parts I need? This seems to return me to my original problem: How do I handle the population after the first page? After I have the next button click result in a save of the data, how do I call an action from this action called that will populate the bean for the next page in line? Can u provide an example scenario of how you might handle a stuation like this or source would be fine as well?

                    • 7. Re: master-detail example
                      Igor Shabalov Apprentice


                      ether all or some key value

                      If you do not want to load all data, you need to keep at least key values (for example object PK(s) and load actual objects on demand using request-scope beans with getters.

                      Note, that "keepAlive" beans must be serialazable.