I have a form that takes some data like name, email address, age etc from the user and submits them into the database. I have a validator that checks to see that the mandatory fields are filled up by the user before inserting the data in the database. So far so good.
I have requirement that should not allow the user who have already entered their data in the database to enter it again. For that I first get the record from the database for a submitted email address. if the record exist in the database for that email address I need to inform the user about it in a fashion that they are taken back to the same form with all the data that they have entered in a prepopulated mode. This is where I am stuck.
I am using controller that extends the SimpleFormController. The URL to get the form is http://servernameort/en-US/responseForm.do. So when the email address exist piece of code isFollowing is my controller declaration in the main-servlet.xml:ModelAndView modelAndView = new ModelAndView("redirect:/en-US/responseForm.do","responseform", userResponse);
//responseform is the name of the command name
I am using tiles and my tiles definition is:<bean id="ttg.responsecontroller" class="com.product.controller.ResponseController">
<property name="sessionForm" value="true" />
<property name="commandName" value="responseform" />
<property name="commandClass" value="com.product.dto.Response" />
<property name="responseService" ref="ttg.responseservice" />
<bean class="com.product.validator.ResponseValidator" />
<property name="formView" value="displayResponseForm" />
<property name="successView" value="responseThankYou" />
</bean>When I redirect using the above code I do get to the form but somewhere my bean "responseform" gets lost and the form is empty. I need the data to be populated.<definition name="displayResponseForm" extends=".mainTemplate" >
<put-attribute name="body" value="/WEB-INF/jsp/pages/product/responseForm.jsp" />
<definition name="en-US/responseThankYou" extends=".mainTemplate" >
<put-attribute name="body" value="/WEB-INF/jsp/pages/product/responseThankYou.jsp" />