Announcement Announcement Module
No announcement yet.
How I can find out the cause of the command object ... Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How I can find out the cause of the command object ...

    I run into this error while bringing up a form:

    ERROR org.springframework.web.servlet.tags.BindTag.doSta rtTag:71 - Neither Errors instance nor plain target object for bean name 'command' available as request attribute
    javax.servlet.jsp.JspTagException: Neither Errors instance nor plain target object for bean name 'command' available as request attribute

    I think the reason is either the command object isn't initiated properly or the object is not saved as a request attribute. For the information I have, I can't see the neither case. The command object class is instanceable and the command is definited in the servlet.xml file as the following:

    <property name="commandName"><value>articleForm</value></property>
    <property name="commandClass"><value> ArticleForm</value></property>

    Any idea on how to find out the cause?

    Thanks very much for any of your inputs in advance.


  • #2
    In the controller, where you're returning the model and view, have you used errors.getModel() as the basis for the model you're returning?

    After a form has successfully been submitted the redirects to the success view won't contain the command object anymore (unless you're explicitly adding it to the model, using errors.getModel()).



    • #3
      Thanks for your response, Alef.

      The command object is not a model object, but a form object which in terms contains a model object. The all methods of the class are below:

      public AddArticleFormController() {
      // need a session to hold the formBackingObject

      protected Map referenceData(HttpServletRequest request)
      throws ServletException {
      logger.debug(""); // called
      Map refData = new HashMap();
      refData.put("categories", cManager.getCategories());
      return refData;

      protected Object formBackingObject(HttpServletRequest request)
      throws Exception {
      logger.debug(""); //called

      User user = (WebAppUtils.getUserSession(request)).getUser();
      if (user == null)
      throw new ServletException("User session unfound");
      return new NewArticleForm(...);

      protected void initBinder(HttpServletRequest request,
      ServletRequestDataBinder binder) throws Exception {
      new ByteArrayMultipartFileEditor());

      protected void onBind(HttpServletRequest request, Object command) {
      logger.debug(""); // not called???
      NewArticleForm entryForm = (NewArticleForm) command;
      int typeId = Integer.parseInt(request.getParameter("catId"));
      Article a = entryForm.getArticle();
      a.setCategory((Category) EntityUtils.getById(cManager
      .getCategories(), Category.class, typeId));

      /** Method inserts a new <code>Entry</code>. */
      protected ModelAndView onSubmit(HttpServletRequest request,
      HttpServletResponse response, Object command, BindException errors)
      throws ServletException {

      NewArticleForm entryForm = (NewArticleForm) command;
      Article entry = entryForm.getArticle();
      // delegate the insert to the Business layer
      return new ModelAndView(getSuccessView(), "ownerId", entry

      The related log messages are the followings:

      DEBUG ewForm:305 - Displaying new form
      DEBUG ackingObject:46 -
      DEBUG inder:58 -
      DEBUG orm:476 - Setting form session attribute [ articleForm] to: [email protected]
      DEBUG enceData:38 -

      The error occurs during the time of bringing up the form, but not submitting the form. I can't see any method other than the onSubmit where I can insert the errors.getModel() call.