Announcement Announcement Module
No announcement yet.
Which controller should I choose Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Which controller should I choose


    I'm implementing a survey form in spring mvc. The questions of the survey form are generated dynamically though DAO so I cannot use a static jsp view page for displaying the form. I dont if the simpleFormController class can allow me to send models to the formview in order to generate the form and them process the data inputed by using onsubmit() method. Will appreciate if anyone give me a clue. Thanks!

  • #2
    Yes, just override the formBackingObject method where you can retrieve probably a map of question vs answer, or some other custom object using your dao. Depending on the type of form backing object you could use a custom editor to bind your data.


    • #3
      Hi maverickthinker,

      Thanks for replying. I think formBackingObject() is used to assemble the custom object from returning data. But before the user can input in the form I need to display the form, which require me to send a model called 'survey' to it. I would like to know how to do it?

      Here is what the survey view will look like:

       <c:forEach items="${survey.questions}" var="question">
          	<li><c:out value="${question.questionDetail.questionContent}"></c:out></li>
          	<c:if test="${question.questionDetail.questionType eq '1'}">
          		<div class="feedback">
          		   	<input type="radio" name="${question.questionId}" value=1 />Excellent	
          		    <input type="radio" name="${question.questionId}" value=2 />Good
      	    		<input type="radio" name="${question.questionId}" value=3 />Average
      	       		<input type="radio" name="${question.questionId}" value=4 />Fair
      	   		    <input type="radio" name="${question.questionId}" value=5 />Poor
      	   		    <input type="radio" name="${question.questionId}" value=0 />N/A			
          	<c:if test="${question.questionDetail.questionType eq '2'}">
          		<div class="feedback">
          			<textarea rows="5" cols="60" name="${question.questionId}"></textarea>