3 Replies Latest reply on Dec 26, 2005 8:26 PM by Gavin King

    Datamodel update cycle

    js8523 Novice

      Hi All

      I recently ran into a problem where I displayed a list of items, I then edited one of those items and returned to the list (@Datamodel), however when I returned the list was not relecting the change.

      The reason was that each time you outject the datamodel, it checks to see whether the items in the list has changed (using equals operator), if it detects no change then obviously it does not repush the same information out to the external context.

      Just a word of warning to anyone as easily confused as me, be careful that your custom implemented equals operator reflects compares all items in your object that are editable, hence notifying the datamodel outjector of a change and a reason to re outject the data.

      I presume this applies to any object for outjecting whether @Datamodel or just @Out.

      A word of warning from a relieved idiot!!

      I don't know how heavy the overhead is for checking for changes in the datamodel (especially for large data sets) compared to the outjection process, but if it does not produce to much overhead, it might just be worth outjecting automatically (not checking for changes), allowing developers to use custom equals operators for other tasks.

      This could be a very silly idea, just my two pennies worth!

      James

        • 1. Re: Datamodel update cycle
          Matthew Edwards Newbie

          Can't you just use the entity manager to persist the datamodel changes and then flush it.

          @PersistenceContext(type = EXTENDED)
          private EntityManager em;
          
          em.persist(dataModel);
          em.flush();


          • 2. Re: Datamodel update cycle
            js8523 Novice

            Sorry to be unclear in the original post.

            It is not about the datamodel field being refreshed in the stateful bean (which it is), it is about whether Seam see's fit to outject into the datamodel again to the http context or whether it doesn't bother because it thinks there is no change so it may as well leave the old one there.

            The way it tells whether it should bother re 'outjecting' the variable is checking whether the http contect variable is 'equal' to the datamodel variable in the stateful session bean.

            Hope this makes more sense.

            James

            • 3. Re: Datamodel update cycle
              Gavin King Master

              Right, I put a lot of effort into getting this functionality just right. equals() is the only really safe way.