@Override
 public QuestionBreadCrumb setBreadCrumb(ModelMap modelMap) {
   FormElement qElement = (FormElement) modelMap.get(COMMAND_NAME);
   if (qElement != null) {
     if (qElement.getForm() == null) {
       BaseForm form = getFormContext();
       qElement.setForm(form);
     }
     QuestionBreadCrumb breadCrumb =
         new QuestionBreadCrumb(qElement.getForm(), qElement.isNew() ? Action.ADD : Action.EDIT);
     modelMap.addAttribute(Constants.BREAD_CRUMB, breadCrumb);
     return breadCrumb;
   }
   return null;
 }
  /**
   * Process data entered by user
   *
   * @param question
   * @param formId
   * @return
   */
  @SuppressWarnings("unchecked")
  @RequestMapping(method = RequestMethod.POST)
  public ModelAndView onSubmit(
      @ModelAttribute(COMMAND_NAME) FormElement qElement,
      BindingResult result,
      @ModelAttribute(LOOKUP_DATA) Map lookupData,
      SessionStatus status,
      HttpServletRequest req,
      @RequestParam(value = IS_EXTERNAL, required = false) String isExternal) {

    validateEditOperation(qElement);

    log.debug("QuestionElement: " + qElement.toString());

    log.debug(qElement.toString());
    Long formId = null;
    boolean isNew = qElement.isNew();
    try {

      if (isNew) {
        // The ExternalQuestionElement can only be created via import.
        formId = getFormId();
        qaManager.addNewFormElement(qElement, formId);
      } else {
        formId = qElement.getForm().getId();

        if (qElement instanceof ExternalQuestionElement) {
          // unlink because of modifications
          ((ExternalQuestionElement) qElement).unlink();
        }
        qaManager.updateFormElement(qElement);
      }
    } catch (PersistenceException e) {
      Throwable t = e.getCause();
      if (t instanceof GenericJDBCException) {
        String message =
            ((GenericJDBCException) t).getSQLException().getNextException().getMessage();
        if (message.indexOf("short name already exists") > -1) {
          if (isNew) {
            qElement.resetId();
            qElement.getDescriptionList().clear();
          }
          int beginIndex = message.indexOf('[');
          int endIndex = message.indexOf(']');
          String shortName = message.substring(beginIndex + 1, endIndex);
          Object[] params = {shortName};
          result.rejectValue(
              "question.shortName", "notunique.shortName", params, "Short name is not unique");
          return new ModelAndView("questionEdit");
        } else {
          throw e;
        }
      } else {
        throw e;
      }
    }

    qElement.setCategories(prepareCategories(req, lookupData));
    //		TODO Save 2 times is not good idea. We clear constraints by second update (see
    // implementation)
    //		Changes to attached to session object save automatically. So categories are seved
    //		qaManager.updateFormElement(qElement);

    // after question is saved - return to question listing
    return new ModelAndView(
        new RedirectView(Constants.QUESTION_LISTING_URI + "?formId=" + formId, true));
  }