2 Replies Latest reply on Dec 10, 2009 12:18 PM by kesson

    EntityHome Update method doesn't update property's value

    kesson
      Hello,
      I am trying to update one of an object's fields to the value entered in a web form. I am doing that exactly as I did with many other entities, directly from the RichFaces page, by calling entityHome.update method, like this:

      <h:commandButton value="Update MyObject" action="#{myObjectHome.update}"/>

      Everything looks well, I've got a printout from the Update() method, that says

      updated entity myApp.entity.MyObject 145

      where 145 is a correct ID for the managed entity. But, in fact, there are no changes in field's value in database. May be the following would be interesting: i tried to dig into the same transaction in other objects, that are updated well and use the  same call to entityHome.update. I noticed, that when performing update of these objects, the setter method of the modified property is called twice. But in case of property that is not willing to be updated, no call to setter method is made, just printing about successful update... Once again - there is nothing specific about problematic entity - everything looks the same as for other entities. Of course, I can workaround this by using some bean and entityManager, but it is pretty silly to do it while all the rest objects in application do it in so simple way. I will appreciate every idea/hint.
      TIA.

        • 1. Re: EntityHome Update method doesn't update property's value
          mikkus70

          The fact that the property setter is not being called makes me think of a problem in form submission, more than a problem in the entity home component. It is not clear how you change the property value, but assuming you're changing it from a control in your page, I would first check the following (ok, these are mostly silly mistakes, but happen all the time to me):



          • the property is in the form you're submitting with that commandButton,

          • the property is being correctly submitted back to the server (check the POST you're passing to the server with FireBug or a similar tool) and is properly converted and validated.

          • 2. Re: EntityHome Update method doesn't update property's value
            kesson
            Hi,

            believe it or not, but I really forgot to embed the appropriate control within <form> tag! I've fixed it and now everything is fine! Thank you a lot for very useful hint:)