Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Spring MVC problem with AbstractWizardFormCOntroller

 
murwath ali
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am putting my code,


spring-servlet.xml
____________________

<?xml version="1.0"?>
<!DOCTYPE beans PUBLIC
"-//SPRING//DTD BEAN//EN"
"http://www.springframework.org/dtd/spring-beans.dtd">
<beans>

<bean name="/controller.spring" class="controller">
<property name="pages">
<list>
<value>courseFeedback</value>
<value>materialProvided</value>
</list>
</property>
</bean>


<!-- code of internalresourceviewresolver -->
<bean id="..."/>
<property name="suffix">
<value>.jsp</value>
</property>
</beans>


coursename.jsp :
________________

/* CourseName.jsp */
<form action="controller.spring">
CourseName :
<input type="text" name="courseName"/>
<input type="submit"/>
</form>


coursefeedback.jsp :
____________________

/* courseFeedback.jsp */
<form action="controller.spring">
CourseFeedback :
<input type="text" name="courseFeedback"/>
<input type="submit" value="Next" name="_target1">
<input type="submit" value="Cancel" name="_cancel">
<input type="submit" value="Finish" name="_finish">
</form>


/* materialProvided.jsp */
______________________


<form action="controller.spring">
MaterialProvided :
<input type="text" name="materialProvided"/>
<input type="submit" value="Back" name="_target0">
<input type="submit" value="Finish" name="_finish">
<input type="submit" value="Cancel" name="_cancel">
</form>

/* controller.java */
________________
import packages.....;

public class controller extends AbstractWizardFormController
{
public controller()
{
setCommandClass(bean.class);
}

protected ModelAndView processFinish(HttpServletRequest request,
HttpServletResponse response, Object command,
BindException errors) throws Exception {
bean b=(bean)command;
System.out.println(b.getCourseName()+" "+b.getCourseFeedback()+" "+b.getMaterialProvided());
return new ModelAndView("success");
}


protected ModelAndView processCancel(HttpServletRequest request,
HttpServletResponse response, Object command,
BindException bindException) throws Exception {
return new ModelAndView("/CourseName.jsp");
}
}



bean.java :
__________

/* bean.java */
public class bean
{
String courseName,courseFeedback,materialProvided;
public void setCourseName(String courseName)
{
this.courseName=courseName;
}
public String getCourseName()
{
return courseName;
}


public void setCourseFeedback(String courseFeedback)
{
this.courseFeedback=courseFeedback;
}
public String getCourseFeedback()
{
return courseFeedback;
}


public void setMaterialProvided(String materialProvided)
{
this.materialProvided=materialProvided;
}
public String getMaterialProvided()
{
return materialProvided;
}}


The problem is when i deploy my app.. in server and lookup the coursename.jsp ,it comes and later goes to controller and later goes to

coursefeedback.jsp and if i click 'next' button present in coursefeedback.jsp , i am not able to navigate to any other page and i am redirected to same coursefeedback.jsp ,The actual page that must be displayed is materialprovided.jsp
 
Elie Hirschman
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try making _target1 a separate form field, instead of part of the submit button:



This has been working for me.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic