Announcement Announcement Module
No announcement yet.
Data Binding Error Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Data Binding Error


    I am using Spring 2.5 MVC.

    I have a controller whihc is used as the commandName of my form. This controller does not extend any class.

    It has a property CriterionBoolean retireCriterion = new CriterionBoolean("retire", Relation.eq, false);
    CriterionBoolean extends CriterionImpl<Boolean>;

    This is bound to a checkbox on my form.
    <form:checkbox path="retireCriterion.value" value="true" cssClass="checkbox" /> Retire</td>

    When I press the submit button on my form, and it tries to get retireCriterion.value() I always get the following error:

    SimpleFormController.processFormSubmission ( >> DEBUG: Data binding errors: 1


    org.springframework.validation.BindingResult.opera torQbeCommand=org.springframework.validation.BeanP ropertyBindingResult: 1 errors


    Field error in object 'operatorQbeCommand' on field 'retireCriterion.value': rejected value [null]; codes [methodInvocation.operatorQbeCommand.retireCriterio n.value,methodInvocation.retireCriterion.value,met hodInvocation.value, ect,methodInvocation]; arguments [ SourceResolvable: codes [operatorQbeCommand.retireCriterion.value,retireCri terion.value]; arguments []; default message [retireCriterion.value]]; default message [Property 'retireCriterion.value' threw exception; nested exception is java.lang.NullPointerException]

    I have the getter and setter for the filed in the controller.

    Any help with this would be of great help to me.


  • #2
    Your story sounds strange, a Controller with a get/set for the property doesn't do much. Post your Controller and Command class...


    • #3
      Here is the code

      The controller used for multiple criteria search on the form:

      public class OperatorQbeCommand {

      // properties releated to multiple criteria

      CriterionInteger regionTypeCriterion;
      CriterionString countryTypeCriterion;
      CriterionInteger networkTypeCriterion;
      CriterionString wirelessTechnologyTypeCriterion;
      CriterionInteger frequencyTypeCriterion;
      String serviceTypeId;
      CriterionBoolean retireCriterion;

      //other properties
      CannedQueryType cannedQueryType;
      int operatorId;

      //................................ the getter and setter for all the above

      public List<CriterionImpl<Object>> getCriterionList() {
      List<CriterionImpl<Object>> criterionList = new ArrayList<CriterionImpl<Object>>();

      for (CriterionImpl criterion : new CriterionImpl[] { regionTypeCriterion, countryTypeCriterion,
      networkTypeCriterion, wirelessTechnologyTypeCriterion, frequencyTypeCriterion, retireCriterion }) {

      //.......SOME BUSINES LOGIC

      return criterionList;

      The aboev controller is used to capture all multiple criteria entered by the user for search and when done, an ajax call is made to another controller as below to display the search results

      public class SearchOperatorFormPageController extends SimpleFormController {

      // -------------------------- properties
      OperatorManager operatorManager;
      ConversationalState conversationalState;
      // The number of the partial search results shown on the search form via AJAX
      private static final int PARTIAL_RESULTS_SIZE = 5;

      public SearchOperatorFormPageController() {
      // need a session to hold the formBackingObject
      // initialize the form from the formBackingObject

      public void setOperatorManager(OperatorManager operatorManager) {
      this.operatorManager = operatorManager;

      public void setConversationalState(ConversationalState conversationalState) {
      this.conversationalState = conversationalState;

      protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
      super.initBinder(request, binder);
      binder.registerCustomEditor(Integer.class, "regionTypeCriterion.value", new CustomNumberEditor(Integer.class, false));
      binder.registerCustomEditor(Integer.class, "networkTypeCriterion.value", new CustomNumberEditor(Integer.class, false));
      binder.registerCustomEditor(Integer.class, "frequencyTypeCriterion.value",
      new CustomNumberEditor(Integer.class, false));


      protected Map<String, List<?>> referenceData(HttpServletRequest request) throws ServletException, NoSuchOperatorException {
      Map<String, List<?>> refData = new HashMap<String, List<?>>();

      //...............................some code


      * This form supports query by example creation
      protected Object formBackingObject(HttpServletRequest request) throws Exception {

      return new OperatorQbeCommand();

      protected ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors)
      throws Exception {

      //..............some code

      return modelAndView;

      protected void onBindAndValidate(HttpServletRequest request, Object command, BindException errors) throws Exception {
      super.onBindAndValidate(request, command, errors);

      protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command,
      BindException errors) throws InvalidSearchCriteriaException, NoSuchOperatorException, NoSuchEntityException,
      Exception {

      //................some business logic

      return forward(operators, request, response, errors);


      private ModelAndView forward(List<Operator> operators, HttpServletRequest request, HttpServletResponse response,
      BindException errors) throws Exception {

      //...........soem code

      return new ModelAndView(getSuccessView(), model);


      My jsp page is as follows:

      <%@ include file="/templates/directives.jspf" %>
      <div class="BlockTitle">
      Multiple Criteria Search
      <div id="operatorQBEBlock" class="Block Search">
      <form:form commandName="operatorQbeCommand"
      onsubmit="javascript:document.getElementById('show PartialResults').value=false"

      <%---- some jsp code --%>

      <form:checkbox path="retireCriterion.value" value="true" cssClass="checkbox" /> Retired</td>

      <%---other search criteria as dropdown boxes --%>

      Access to above "retireCriterion.value" always throws an error