Announcement Announcement Module
Collapse
No announcement yet.
Problem with <spring:bind> Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problem with <spring:bind>

    I am using the <spring:bind> tag to access the model data in order to display/edit it on my JSP page. Say for example, if there are 4 fields on the form out of which user enters a wrong value for one which is successfully picked up by the validator and displayed again. However the other 3 fields are still persisted to the database. Is this the regular behavior of <spring:bind> tag?? I donít want that. I want that even if one is wrong everything else should be rejected.

    How do I do that?

    Any kind of help would be really appreciated.
    Thanks
    Manpreet Minhas

  • #2
    Hi Manpreet,

    I assume that you used SimpleFormController and overrided the referenceData() method which called your biz service/dao service to load reference data (lookup, etc.). So when you submit the form --> validator runs --> errors --> reload the form --> call referenceData() again --> your hibernate session (I assume) will be auto-flushed --> your "dirty" data will be saved.

    The solution is to declare the form as sessionForm, e.g.
    Code:
    <bean id="xxxController" class="XXXController">
    		<property name="sessionForm">
    			<value>true</value>
    		</property>
    ...
    </bean>
    Hope this helps
    Ngoc
    Last edited by ngoctay; Jan 18th, 2006, 08:14 PM.

    Comment


    • #3
      Thanks

      Thanks a lot for your help. It did the trick.

      Thanks once again.
      Manpreet Minhas

      Comment


      • #4
        Another trouble..

        Hi again,

        If i change the sessionForm property to true as suggested by you. First time when i save the object it works fine but if i again openit for editing purposes and after making the dessired changes when i hit the save button it gives me the following exception

        org.springframework.orm.hibernate.HibernateSystemE xception: a different object with the same identifier value was already associated with the session

        Any idea what am i doing wrong now??

        Thanks in advance.
        Manpreet Minhas

        Comment


        • #5
          Hmmm, I got this problem before but cannot remember how to fix it

          Try the following, maybe it helps
          Code:
          <bean name="openSessionInViewInterceptor" class="org.springframework.orm.hibernate3.support.OpenSessionInViewInterceptor">
              	...
          	<property name="singleSession">
          		<value>false</value>
          	</property>
          </bean>
          If it still appears, please post your application context
          Last edited by ngoctay; Jan 18th, 2006, 11:37 PM.

          Comment

          Working...
          X