I'm trying to talk to this request handler (sorry about the bad language, I'm brand new to spring, I think that's what it's called). I've looked around and seen recommendations to set the logging level to DEBUG
, I talked to our lead about it he asked that I not spend time with that. I'm running out of ideas, I've googled around and looked at a whole lot of stack overflows and can't seem to find my way.
Here's my controller:
@RequestMapping(value={"/project/save", "/project/add", "/project/edit"}, method=RequestMethod.POST)
public ModelAndView saveProject(@ModelAttribute ProjectForm form) {
ModelAndView mav = this.createBaseModelAndView("project/start");
ModelAndView redirect = new ModelAndView("redirect:/admin/projects");
return this.projectUtils.saveProject(form, mav, redirect);
}
Sending these vars in the request:
projectId: 51c4619c036492494eca2740
vendorId: 5113babc0364a6e3eb6aa368
name: Cedar Goodies
description: ldfkj
url: http://caseywise.com
openDate: 06/22/2013 12:00 AM
closeDate: 06/26/2013 12:00 AM
organizerId: 517da4b92e3a896d9c613b2e
allowIndividualShipping: false
allowIndividualPayments: false
allowOrderEditing: false
items[0]: 51c461a9036492494eca2741
And these request headers
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Encoding: gzip,deflate,sdch
Accept-Language: en-US,en;q=0.8
Cache-Control: no-cache
Connection: keep-alive
Content-Length: 366
Content-Type: application/x-www-form-urlencoded
Cookie: JSESSIONID=6eebd82250b5429bfd8bb5f82e42
Host: localhost:8080
Origin: http://localhost:8080
Pragma: no-cache
Referer: http://localhost:8080/admin/project/start
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.116 Safari/537.36
the ProjectForm object (from the saveProject method in the controller) wants these properties
private String projectId;
private String name;
private String description;
private Date openDate;
private Date closeDate;
private String organizerId;
private List<String> items; // hidden inputs for form submission, since we can't send an object through a form
private String url;
private boolean allowOrderEditing;
private boolean allowIndividualPayments;
private boolean allowIndividualShipping;
private String vendorId;
I'm getting back a 400 - The request sent by the client was syntactically incorrect ()
. Do you see any glaring errors? Do you want to see more code? Any ideas?
EDIT
Including the ProjectForm
object per Pavel's comment:
package com.ordercollector.viewmodels.project;
import com.ordercollector.controllers.utils.ControllerUtils;
import com.ordercollector.entities.ProjectItem;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import org.apache.http.impl.cookie.DateParseException;
import org.apache.http.impl.cookie.DateUtils;
import org.jboss.logging.Logger;
/**
*
* @author jables
*/
public class ProjectForm {
private String projectId;
private String name;
private String description;
private Date openDate;
private Date closeDate;
private String organizerId;
private List<String> items; // hidden inputs for form submission, since we can't send an object through a form
private String url;
private boolean allowOrderEditing;
private boolean allowIndividualPayments;
private boolean allowIndividualShipping;
private String vendorId;
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @param description the description to set
*/
public void setDescription(String description) {
this.description = description;
}
/**
* @return the openDate
*/
public Date getOpenDate() {
return openDate;
}
public String getOpenDateFormatted() {
return ProjectForm.formatDateAsString(openDate);
}
/**
* @param openDate the openDate to set
*/
public void setOpenDate(Date openDate) {
this.openDate = openDate;
}
/**
* @return the closeDate
*/
public Date getCloseDate() {
return closeDate;
}
/**
* Returns the project's close date in a formatted string. If the close
* date has not been set, an empty string is returned.
* @return String
*/
public String getCloseDateFormatted() {
return ProjectForm.formatDateAsString(closeDate);
}
/**
* @param closeDate the closeDate to set
*/
public void setCloseDate(Date closeDate) {
this.closeDate = closeDate;
}
/**
* @return the organizerId
*/
public String getOrganizerId() {
return organizerId;
}
/**
* @param organizerId the organizerId to set
*/
public void setOrganizerId(String organizerId) {
this.organizerId = organizerId;
}
/**
* @return the item
*/
public List<String> getItems() {
return items;
}
/**
* @param item the item to set
*/
public void setItems(List<String> items) {
this.items = items;
}
/**
* @return the url
*/
public String getUrl() {
return url;
}
/**
* @param url the url to set
*/
public void setUrl(String url) {
this.url = url;
}
/**
* @return the projectId
*/
public String getProjectId() {
return projectId;
}
/**
* @param projectId the projectId to set
*/
public void setProjectId(String projectId) {
this.projectId = projectId;
}
/**
* @return the allowOrderEditing
*/
public boolean getAllowOrderEditing() {
return allowOrderEditing;
}
/**
* @param allowOrderEditing the allowOrderEditing to set
*/
public void setAllowOrderEditing(boolean allowOrderEditing) {
this.allowOrderEditing = allowOrderEditing;
}
/**
* @return the allowIndividualPayments
*/
public boolean getAllowIndividualPayments() {
return allowIndividualPayments;
}
/**
* @param allowIndividualPayments the allowIndividualPayments to set
*/
public void setAllowIndividualPayments(boolean allowIndividualPayments) {
this.allowIndividualPayments = allowIndividualPayments;
}
/**
* @return the allowIndividualShipping
*/
public boolean getAllowIndividualShipping() {
return allowIndividualShipping;
}
/**
* @param allowIndividualShipping the allowIndividualShipping to set
*/
public void setAllowIndividualShipping(boolean allowIndividualShipping) {
this.allowIndividualShipping = allowIndividualShipping;
}
/**
* Returns the given date in the format used by the form. If date object
* is null, an empty string is returned.
* @param date
* @return String
*/
public static String formatDateAsString(Date date) {
if (null == date)
{
return new String("");
}
else
{
DateFormat df = new SimpleDateFormat("MM/dd/yyyy h:mm a");
return df.format(date);
}
}
/**
* @return the vendorId
*/
public String getVendorId() {
return vendorId;
}
/**
* @param vendorId the vendorId to set
*/
public void setVendorId(String vendorId) {
this.vendorId = vendorId;
}
}