aspose file tools*
The moose likes Other Application Frameworks and the fly likes Need help with a SimpleFormController Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "Need help with a SimpleFormController" Watch "Need help with a SimpleFormController" New topic
Author

Need help with a SimpleFormController

Hakan Axheim
Greenhorn

Joined: Nov 24, 2008
Posts: 9
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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help with a SimpleFormController