2 Replies Latest reply on Mar 5, 2008 8:00 AM by sander

    Natural conversations (mis_ab)use for editing entities

    sander

      I'd like to use the the natural conversations for editing my entities so that I can use AJAX validation without the entities being synced with the database.


      The problem is that for every 'id' a new conversation is created. I have thousands of objects in the db which may result in a huge number of conversations, providing for a nice way to attack the server slurping it's memory. I have not tested this but I think it will have a nice effect.


      Is there a way to limit the number of conversations, say for every conversation name only x are allowed? Or is there some other way to prevent this ?
      Or is there a better way to edit entities ?


      The other point is the conversation parameter-value:
      How do I access this in the bean? I now use RequestParameter to get the id but since it also represents the conversation id I guess I can also get it some other way..??



      I use the following code for editing a entity


      pages.xml


      <conversation name="EditReleaseConversation" 
              parameter-name="id"
              parameter-value="#{release.id}" />
      
      <page view-id="/music/releaseForm.xhtml" 
              conversation="EditReleaseConversation"
              action="#{releaseForm.begin}">
      </page>
      



      action class


      @RequestParameter("id")
      private Integer releaseId;
              
      @In(required = false) 
      @Out(required = false)
      private Release release;
              
      @Begin(flushMode=FlushModeType.MANUAL, join = true)
      public void begin() {
              if(release != null)
                      return;
              
              release = em.find(Release.class, releaseId);
      }