Results 1 to 5 of 5

Thread: Problem with <spring:bind>

  1. #1
    Join Date
    Jul 2005
    Posts
    8

    Default 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. #2
    Join Date
    Jan 2006
    Posts
    2

    Default

    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 at 08:14 PM.

  3. #3
    Join Date
    Jul 2005
    Posts
    8

    Default Thanks

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

    Thanks once again.
    Manpreet Minhas

  4. #4
    Join Date
    Jul 2005
    Posts
    8

    Unhappy 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

  5. #5
    Join Date
    Jan 2006
    Posts
    2

    Default

    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 at 11:37 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •