2 Replies Latest reply on Sep 10, 2007 11:45 AM by tuxzilla

    ajax support in a form causes OptimisticLockException

    tuxzilla

      I have a form that has a required field of which I use <a:support/> to validate:

      
      <h:form>
       <s:decorate id="descriptionDecoration" template="WEB-INF/layout/edit.xhtml">
       <ui:define name="label">Description</ui:define>
       <h:inputTextarea value="#{userBean.instance.description}" required="true"
       style="width:250px;" rows="6">
       <a:support event="onblur" reRender="descriptionDecoration"/>
       </h:inputTextarea>
       </s:decorate>
      ...
       <h:commandButton value="next"
       image="images/btn_next.gif"
       action="#{userBean.update}"/>
      </h:form>
      

      The required field will do an Ajax request when focus leaves the field. I have a problem when I change this field and immediately submit the form, the session (associated with userBean.instance) will flush twice. Once due to the Ajax submission, once due to userBean.update invocation. This causes an OptimisticLockException. My question is why the session will try to flush in the Ajax request, and how do I avoid that? I am using Seam 2.0.0 Beta and Ajax 1.1.1. If I edit this required field and then move the focus elsewhere before the submission, the submission will be fine because I'll get a new copy of the entity to update on.

      Thanks.