4 Replies Latest reply on Feb 23, 2007 7:35 AM by pnorman4

    DataModelSelection property not set after using the back but

    pnorman4

      Hi,

      I have a navigation problem in my Seam app.

      A have a standard h:dataTable with links (s:link) to a "detail view" (much like the hotel booking demo). To find out what row was clicked, I use @DataModelSelection.

      xhtml:

      <s:link action="#{mainBean.selectListItem}" value="Open" />


      mainBean (ScopeType.SESSION):
      @DataModelSelection("mainListItems")
       private ContentListItem selectedListItem;
      
       public String selectListItem() {
       return setCurrentObject(selectedListItem);
       }
      


      The first time a click the link, the annotated property selectedListItem is set, my selectListItem action method is called and the detail view is shown correctly.

      If I then use the back button, the list is shown again. But if I then click another row in the list, the selectedListItem property is not updated and the old detail view will be shown again!

      The scenario is the same independent of if I'm in a conversation or not.

      If I refresh the list screen after using the back button, the links works properly!

      Am I doing something wrong? I can't find anything in the documentation about special configuration that's neede to get back button to work.

      /Per

        • 1. Re: DataModelSelection property not set after using the back
          mjek2

          AFAIK it works fine in Seam examples (and I also use @DataModelSelection in my app, it works even after back button usage, I'm currently on Seam1.1.1). Do you have just one @DataModelSelection in your component? Could you show some more code (complete xhtml page and related java components)? StackTrace if any? Seam/JSF version?

          • 2. Re: DataModelSelection property not set after using the back
            pnorman4

            Actually, I'm using four different @DataModel. Three of these have their own @DataModelSelection.

            The page is composed of a page with a table (uses mainListItems). and a small list of selected items (populated by selectedListItems).

            The page uses a facelet template, which contains a menu (populated by leftMenuList), and a special list (populated by oPoolItems).

            The main table looks like this (i'm not sending complete xhtml listings for all 6 files yet):

            <h:dataTable value="#{mainListItems}" var="listItem" id="mooxTable">
             <h:column>
             <h:outputText value="(#{listItem.localItem.title}) "/>
             </h:column>
            
             <!-- Open -->
             <h:column>
             <s:link action="#{mainBean.selectListItem}" value="S:Open"/>
             </h:column>
            
            </h:dataTable>
            


            The other lists are rendered in the same way.

            The link navigates to a new detail page, with the same template.

            The bean looks like this:
            @Name("mainBean")
            @Scope(ScopeType.SESSION)
            public class MainBean extends AbstractSeamBean {
            
             /* REMOVED: Import of referenced beans */
            
             /**
             * This list contains the select list items.
             */
             @DataModel
             private List<ContentListItem> selectedListItems = new ArrayList<ContentListItem>();
            
             /**
             * This is the current content of the main content area.
             */
             @Out(required = false)
             private ContentListItem currentMainObject = new ContentListItem(0, new MooxMock("Nothing"));
            
             public boolean isCurrentList() {
             return (null != currentMainObject && currentMainObject.getLocalItem() instanceof MooxList);
             }
            
            
             /**
             * This is the data model for the left menu.
             */
             @DataModel
             private List<ContentListItem> leftMenuList;
            
             @DataModelSelection("leftMenuList")
             private ContentListItem selectedLeftMenItem;
            
             @Factory("leftMenuList")
             public void loadMenu() {
             /* REMOVED: "leftMenuList" initialization */
             }
            
             public String selectLeftMenuItem() {
             return setCurrentObject(selectedLeftMenItem);
             }
            
            
             /**
             * This is the data model for the list view.
             */
             @DataModel
             @SuppressWarnings({"MismatchedQueryAndUpdateOfCollection"})
             private List<ContentListItem> mainListItems = new ArrayList<ContentListItem>();
            
             @DataModelSelection("mainListItems")
             private ContentListItem selectedListItem;
            
             @Factory("mainListItems")
             public void updateListItems() {
             /* REMOVED: "mainListItems" initialization */
             }
            
             /**
             * Action method used when selecting a list view item.
             *
             * @return Navigation.
             */
             public String selectListItem() {
             return setCurrentObject(selectedListItem);
             }
            
             /**
             * Sets a list item as the new object for the main area.
             *
             * @param newObject The new object to show in main area.
             * @return Navigation.
             */
             public String setCurrentObject(ContentListItem newObject) {
             log.debug("** MainBean - setCurrentObject: #0", currentMainObject);
            
             currentMainObject = newObject;
             updateListItems();
            
             return (isCurrentList() ? "listSelected" : "objectSelected");
             }
            
            
             /**
             * O-pool.
             */
             @DataModel
             private List<ContentListItem> oPoolItems;
            
             @DataModelSelection("oPoolItems")
             private ContentListItem selectedOpoolItem;
            
             @Factory("oPoolItems")
             public void updateOPoolItems() {
             /* REMOVED: "oPoolItems" initialization */
             }
            
             /**
             * Action method used when selecting an O-pool item.
             *
             * @return Navigation.
             */
             public String selectOpoolItem() {
             return setCurrentObject(selectedOpoolItem);
             }
            
            }
            


            There are no stack traces or errors.

            We're using
            Seam 1.1.6, MyFaces 1.1.5, Facelets 1.1.12, Ajax4JSF 1.0.6.

            /Per

            • 3. Re: DataModelSelection property not set after using the back
              mjek2

              You call updateListItems() from setCurrentObject() which in turn is called when the user selects something from the list using s:link. If updateListItems() manipulates mainListItems I can imagine that it could cause your problem. Did you try to remove updateListItems() from setCurrentObject()? And do you observe your problem only when using back button?

              • 4. Re: DataModelSelection property not set after using the back
                pnorman4

                That's it!! I'm reloading the list when entering detail view. Of cours I can't go back to thelist again. Completely logical now when I see it.

                I removed the updateListItems() call and now it works!!

                You're my hero!

                Per