Announcement Announcement Module
Collapse
No announcement yet.
Storing Object in session when validation error happens Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Storing Object in session when validation error happens

    hello guys,

    I started working on spring 2-3 months back so i am new for spring. Following is the issue I am facing in my spring MVC application -

    When i submit page, i store Command object(i.e. form) in session in controller. I have overwritten onSubmit(HttpServletRequest request,HttpServletResponse response, Object command, BindException errors) method and store command object in session in this method. So when saves/submits form, after completing database save operation user can see changes he made in GUI.

    I am also using Spring validation framework for some application validation. So if any error is occured in validator class it directly goes to Spring framework so I am not able to store Command object in session and user loses changes his GUI changes.

    Is there any way i can store command object in session when validation error happens ?

  • #2
    That is normally the default behavior, if that isn't happening something is wrong with your setup.

    Comment


    • #3
      Thanks Marten for reply !!!

      So do you mean Spring by default store command object in session ?

      If yes, Where we need to specify so that spring will store command object in session. This is my config file for controller.

      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
      "http://www.springframework.org/dtd/spring-beans.dtd">
      <beans>
      <bean id="efxFormController"
      class="com.capitalone.atlas.web.controller.EFXForm Controller"
      parent="baseFormController">
      <property name="commandName">
      <value>efxFormCommand</value>
      </property>
      <property name="commandClass">
      <value>
      com.capitalone.atlas.web.valueobject.EFXFormComman d
      </value>
      </property>
      <property name="validator">
      <bean class="com.capitalone.atlas.Validator.EFXFormValid ator" />
      </property>
      <property name="formView">
      <value>efx</value>
      </property>
      <property name="successView">
      <value>efx</value>
      </property>
      </bean>
      </beans>

      Comment


      • #4
        Please use [ code][/code ] tags when posting code.

        It is not the default to store an object in the session it is the default to retain the user entered values and validation errors. That should happen out of the box. Also why would you need to store the object in the session, the object would be still available or store it in the model, I wouldn't store it in the session.

        Comment

        Working...
        X