Announcement Announcement Module
No announcement yet.
Neither referenceData nor formBackingObject are called Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Neither referenceData nor formBackingObject are called

    I implemented several SimpleFormController without any problems, but this time my referenceData and formBackingObject methods are not being called and I have no idea why. Here is a simplified version of my Controller:
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import org.apache.log4j.Logger;
    import org.springframework.web.servlet.mvc.SimpleFormController;
    import org.springframework.web.servlet.ModelAndView;
    public class MyController extends SimpleFormController {
      private static Logger LOGGER = Logger.getLogger(MyController.class);
      protected ModelAndView onSubmit(Object formBackingObject) throws Exception {
        Map<String, Object> model = new HashMap<String, Object>();
        return new ModelAndView(this.getSuccessView(), model);
      protected Object formBackingObject(HttpServletRequest request) throws Exception {"[FORM BACKING OBJECT]");
        List <Item> selectedItems = ItemRepository.getSomeItems();
        return selectedItems;
      protected Map<String,List<Item>> referenceData(HttpServletRequest request) throws Exception {"[REFERENCE DATA]");
        Map<String,List<Item>> model = new HashMap<String,List<Item>>();
        List<Item> allItems = ItemRepository.geAllItems();
        model.put("allItems", allItems);
        return model;
      public ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {"[HANDLE REQUEST INTERNAL]");
        Map<String, Object> model = new HashMap<String, Object>();
        return new ModelAndView(this.getFormView(), model);
    The logger is never called and in my JSPs no data is being received for the form.

    This is part of my formView jsp:
      <spring-form:checkboxes path="selectedItems" items="${allItems}"/>
    BTW: I assume the path is wrong, but the methods above should be called although.

  • #2
    It is because you override the handleRequestInternal method screwing up the normal path of execution for the SimpleFormController. So either call super.handleRequestInteral or don't override it.


    • #3
      Thank you! Problem solved.