8 Replies Latest reply on Apr 14, 2007 8:06 PM by delphi'sghost

    DataModelSelection not updated

    hispeedsurfer

      Hi,

      have a table and use row selection with DataModelSelection. If the whole table is loaded all is perfect. But when I use searchpattern like in booking example(ajax) to reduce tablesize DataModelSelection not updated. For example all times the first row from whole table is selected while this row no longer exist in reduced table.

      public abstract class AbstractListBean<T extends BaseEntity>implements Serializable {
      
       protected String searchString;
      
       @PersistenceContext
       protected EntityManager em;
      
      
       @DataModelSelection
       private T selectedEntity;
      }
      


      @Stateful
      @Scope(ScopeType.CONVERSATION)
      @Name("specialreleaselist")
      @SuppressWarnings("unchecked")
      public class SpecialreleaseListBean extends AbstractListBean<SpecialRelease> implements
       SpecialreleaseList {
      
       /**
       *
       */
       private static final long serialVersionUID = 1L;
      
      
       @In
       FacesMessages facesMessages;
      
       @DataModel
       protected List<SpecialRelease> sprTablelist;
      
      
       @Factory("sprTablelist")
       public void find(){
       sprTablelist = loadList();
       }
      @Factory(value="specialreleasepattern", scope=ScopeType.EVENT)
       public String getSearchPattern(){
       return searchString==null ?
       "%" : '%' + searchString.toLowerCase().replace('*', '%') + '%';
       }
      
      
       protected List<SpecialRelease> loadList() {
       List readFromDB = null;
       readFromDB = readFromDB("select s from SpecialRelease s where lower(s.description) like #{specialreleasepattern}");
      
       return readFromDB;
       }
      }


      What is the right way updating DataModelSelection?


      Thanks
      Andi

        • 1. Re: DataModelSelection not updated
          hispeedsurfer

          Helllo,

          no idea why the selected datamodel not updated? Only the sequence from whole table are existent in reduced table.


          Thanks
          Andi

          • 2. Re: DataModelSelection not updated
            pmuir

            Try using page parameters or the seam el enhancement instead

            • 3. Re: DataModelSelection not updated
              hispeedsurfer

              Hi Pete,

              I don't know what you mean. Neither page parameters nor el enhancement should be used for my problem.

              First time I load a table with all entries. When I select a row, the correspondending entity is displayed on the bottom of the page.

              Then I use search to reduce the table with this one

              <a:region id="searchRegion" renderRegionOnly="false">
               <h:inputText id="searchString" value="#{specialreleaselist.searchString}" style="width: 165px;">
               <a:support event="onkeyup" actionListener="#{specialreleaselist.find}" reRender="searchResults, lowerform" requestDelay="1" />
               </h:inputText>
               </a:region><!-- End searchRegion -->
              


              A few entries are display now, but when I select on of these (i.e. the first one) the displayed entity is this one from whole table of the first load.

              Why DataModelSelection not updated on search result table? There should be a possibility to refresh the DataModelSelection!

              Have no idea to solve this with el or page parameters


              Thanks

              • 4. Re: DataModelSelection not updated
                pmuir

                Actually, imo, page parameters (or the el enhancement) are the best way to do an entity selection from a table - the @DataModel/@DataModelSelection stuff I don't use anymore.

                Take a look at the booking example for how to do it with EL enhancement, or at a seam-gen'd app or the reference manual for how to use page parameters.

                • 5. Re: DataModelSelection not updated
                  hispeedsurfer

                  Hi Pete,

                  thank you for your suggestion. I use now el enhancement and it works.


                  Bye
                  Andi

                  • 6. Re: DataModelSelection not updated
                    delphi'sghost

                    What is this El Enhancement that you speak of?

                    When you say page parameters, I assume you mean passing the Id of the object to be edited from the search page to the edit page as a parameter of the URL..i.e. editperson.xhtml?PersonId=123 ?

                    I've been thinking about the issue of moving objects from page to page recently, and I realized that Seam gives you multiple ways of doing it.
                    I'm trying to find a way where we can be consistent that won't trip us up down the line. Since the different methods are all easy give or take a few lines of code, page parameters offers the advantage of bookmarkable URLs.

                    What might be nice to see is some kind of VERY simple crud app that is in pure seam (as opposed to the framework stuff) that includes the different methods of passing objects, or at least indicates some kind of best practices. However, I know how busy you guys are.


                    • 7. Re: DataModelSelection not updated
                      hispeedsurfer
                      • 8. Re: DataModelSelection not updated
                        delphi'sghost

                        Ah, OK, thats the EL enhancement, I had seen it, just didn't realize that was what it was called.

                        My only problem with the el enhancements is using it in pages.xml since in order to refer to it as an outcome, you need to include the whole expression, including the variable name i.e.

                        HotelBooking.selectHotel(hot)


                        which means if you change the iterator variable name in the jsf page you break your navigation. I think I'll stick with the parameters, especially since it gives you bookmarkable links.