jeudi 26 mars 2015

Neither BindingResult nor plain target object for bean name 'testCheck' available as request attribute When Attempting To Set up Boolean CheckBox

OK, I am new to Spring MVC, but I am trying to do something quite simple. I am adding a checkbox adjacent to a search input that will make it so that if the user clicks the check box all the content whether it has been previously deleted or not will come back in the search.


Now I have not even gone about setting up that functionality, but already have that part figured out. However, I started to set up the basics for the checkbox itself which will be a simple Boolean, and it throws the following error when I go the page in the stack trace.


Neither BindingResult nor plain target object for bean name 'testCheck' available as request attribute


Can anyone look through what I have here and tell me what I need to add to at the very least get the page to load? I'm not asking about how to make it function, I already have that in mind.


Here is what I have in my JSP



<label for="active">Show All Employees:</label>
<form:checkbox path="testCheck" />


Here is what I have for it in my bean, and it's set up in my employee.java bean which has no other problems at this point.



boolean testCheck;

public boolean isTestCheck() {
return testCheck; }

public void setTestCheck(boolean testCheck) {
this.testCheck = testCheck
}


Stopping right here for a moment, everything else in my bean is a column. This is not. Should I make this a column, every example I've seen this far does not show a Boolean checkbox being set as a column?


Finally, here's what I have in my controller thus far, although the error was throwing before I started adding to my controller, and to reiterate, I haven't added any of the functionality I am planning to this.


This is only a method in a longer controller



@RequestMapping("/viewer")
public ModelAndView loadViewerPage(

@RequestParam(value = "testCheck", required = false) boolean testCheck,




Aucun commentaire:

Enregistrer un commentaire