Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8326785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:53:02+00:00 2026-06-09T00:53:02+00:00

I have a form that gets populated with data from the database. Before is

  • 0

I have a form that gets populated with data from the database.
Before is start describing my problem, some snippets:

One class:

// @Entity for areas
public class Area {
@Id
@Column(name = "area")
private String area;

@Column(name = "deleted")
private boolean deleted;

getter/setter
}

Second class

// @Entity for employees
public class Employee {
@Id
@GeneratedValue
@Column(name = "ID")
private long id;

@ManyToOne
@JoinColumn(name = "area")
private Area area;

@Column(name = "name")
private String name;

getter/setter

The method in EmployeeController called to return data to the jsp

protected String createDialog( @PathVariable("id") Long id, Model model ){
    Employee employee = id == 0 ? new Employee() : employeeService.findById(id);
    //return employee
    model.addAttribute("employeeModel", employee );
 //add data needed to create dropdown holding areas
    //areaService.findAll returns a List<Area>
    model.addAttribute("areas", areaService.findAll( 
                new Sort( 
                    Sort.Direction.ASC,
                    "area"
                    )
                ));
    return "employees/dialogUpdateEdit";
}

The jsp, showing the dropdown for the areas and, if no new employee is returned, the known data

<form:form action="employees/ajax" commandName="employeeModel" method="POST" id="createForm">
    <table class="fullWidth">
        <tr>
            <td>Area</td>
            <td>
                <form:select path="area" items="${areas}" class="fullWidth">
                </form:select>
            </td>
        </tr>
        <tr>
            <td>Employee Name</td>
            <td><form:input path="name" class="fullWidth"/></td>
        </tr>
        <tr>
            <td colspan="2">
                <input type="submit" value="Save Changes" id="btnSaveEmployee" class="fullWidth" />
            </td>
        </tr>
    </table>

    <!-- adding hidden field to hold id on update -->
<form:hidden path="id" />   

</form:form>

The controller method doing validation and either returning some errors or not

@RequestMapping(value = "/ajax", method = RequestMethod.POST)
protected @ResponseBody ValidationResponse createOrUpdate(
        @Validated @ModelAttribute("employeeModel") Employee employee,
        BindingResult bindingResult) {

    if (!bindingResult.hasErrors()) {
        employeeService.createOrUpdate(employee);
    }

    return validate(employee, null, bindingResult);
}

For the problem:
This all works fine, dropdown is populated, data gets filled into the inputs.
But when I click the submit, I get the following error:

java.lang.IllegalStateException: Cannot convert value of type
[java.lang.String] to required type [com.whatever.Area] for property
‘area’: no matching editors or conversion strategy found

As far as I understand it, the form just submits the plain string for ‘area’ instead of binding the objects from the List.

How can I get the form to submit the object and not the string? is something wrong with my binding?

Thanks for your help!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T00:53:05+00:00Added an answer on June 9, 2026 at 12:53 am

    To answer my own question and in the hope that the guy gets lot of credits who helped me without knowing 😉

    I had to add a custom binder… Never heard of that before so I asked the long way first.

    This link has the best and shortest tutorial on that subject I found since I knew what I was looking for:
    http://empire5.com/development/binding-a-custom-object-in-spring-3/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey, I have a CheckBoxList that gets populated with the database. When I make
I have a textbox in a form field that gets populated by the user.
I have created a list form that gets attached to a main form in
I have a method, -(void)validateFormInput:(UITextField *)textField that gets called when the form's submit button
I have a form that I want to be validated before showing it initially.
Hi I have the following view that gets the values for the form fields
I have two DropDown lists which are already populated from the database. If you
I have a form that gets submitted using jQuery's .post(). In the corresponding view
In ExtJs4, I have a form with a combo box, where the data gets
Background : I have a GridView which gets populated from an SqlDataSource via DataSourceID.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.