• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Need help with a SimpleFormController

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm a newbie at Spring framework therefore I need to ask a question in this forum. This is an extract from my servlet.xml file;

<bean name="/createProject.htm" class="businessLayer.controller.CreateProjectController">
<property name="sessionForm" value="true"/>
<property name="formView" value="createProject"/>
<property name="successView" value="readProject"/>
<property name="projectService" ref="projectService"/>
</bean>

I wan't to create an JSP page where I enter some data regarding a project that I wan't to create. This is an extract from my createProject.jsp;

<form:form commandName="project" method="post">
ProjectNr:
<spring:bind path="project.projectNr">
<input type ="text" name="projectNr" value="${status.projectNr}"/>
</spring:bind>
<br>
ProjectName:
<spring:bind path="project.projectName">
<input type = "text" name = "projectName" value="${status.projectName}"/>
</spring:bind>
</br>
<input type="submit" name = "Create Project" value = "Create Project"/>
<input type="reset" name="Rensa" value="Rensa"/>
</form>

My formBackingObject looks like this;

protected Object formBackingObject(HttpServletRequest request)
{

logger.info("Inne i formBackingObject");

try {
project.setProjectNumber(ServletRequestUtils.getRequiredIntParameter(request, "projectNr"));
project.setProjectName(ServletRequestUtils.getRequiredStringParameter(request, "projectName"));
project.setStartDate(ServletRequestUtils.getRequiredStringParameter(request, "startDate"));
project.setEndDate(ServletRequestUtils.getRequiredStringParameter(request, "endDate"));
} catch (ServletRequestBindingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

logger.log(Level.INFO,String.valueOf(project.getProjectNumber()));

projectService.createProject(project);
return projectService;


}

and my onSubmit method looks like this;

public ModelAndView onSubmit(Object command) throws ServletException {

logger.info("Inne i CreateProjectController");

projectService.createProject(project);

project.setProjectNumber(((Project) command).getProjectNumber());

logger.log(Level.INFO,"onSubmit: ProjectNumber ",((Project) command).getProjectNumber());


// projectDao.setProjectNr(projectNumber);

// logger.info("ProjectNr " + projectNumber);

// projectService.createProject(projectDao);

return new ModelAndView(new RedirectView(getSuccessView()));

}

No data will be passed in to the formBackingObject from the JSP page. I don't know why! Is it wrong in my JSP page or is it normal?

Can someone help me with this?
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic