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 8518991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:07:38+00:00 2026-06-11T06:07:38+00:00

I was building an simple application using spring roo. After doing certain job, I

  • 0

I was building an simple application using spring roo. After doing certain job, I have removed roo completely.

So here is my controller methods for creating new data..

@RequestMapping(params = "form", produces = "text/html")
public String createForm(Model uiModel) {
    populateEditForm(uiModel, new PatientDetails());
    return "patientdetailses/create";
}

 @RequestMapping(method = RequestMethod.POST, produces = "text/html")
public String create(@Valid PatientDetails patientDetails,
        BindingResult bindingResult, Model uiModel,
        HttpServletRequest httpServletRequest) {

    if (bindingResult.hasErrors()) {
        populateEditForm(uiModel, patientDetails);
        return "patientdetailses/create";
    }
    uiModel.asMap().clear();

    patientDetailsService
            .savePatientDetails(setCurrentUser(patientDetails));
    return "redirect:/patientdetailses/"
            + encodeUrlPathSegment(patientDetails.getId().toString(),
                    httpServletRequest);
}

 void populateEditForm(Model uiModel, PatientDetails patientDetails) {
    uiModel.addAttribute("patientDetails", patientDetails);
    addDateTimeFormatPatterns(uiModel);
    uiModel.addAttribute("sexes", Arrays.asList(Sex.values()));
    uiModel.addAttribute("typeOfPatients",
            typeOfPatientService.findAllTypeOfPatients());
}

my domain:

 public class PatientDetails {

@NotNull
@NotBlank
@NotEmpty
@Size(max = 40)
private String firstName;

@NotNull
@NotBlank
@NotEmpty
@Size(max = 40)
private String lastName;

@Size(max = 40)
private String middleName;

@Size(max = 200)
@NotNull
@NotBlank
@NotEmpty
private String address;

@NotNull
@NotBlank
@NotEmpty
private String city;

@NotNull
private String province;

@NotNull
@Size(max = 5)
private String postalCode;

@NotNull
@Email
@Size(max = 100)
private String email;

@Size(max = 12)
private String homePhone;

@Size(max = 12)
private String workPhone;

@NotNull
private Sex sex;

@Past
@Temporal(TemporalType.TIMESTAMP)
@DateTimeFormat(style = "M-")
@NotNull
private Date dateOfBirth;

@NotNull
@Size(max = 10)
private String socialSecurityName;

@NotNull
@Size(max = 100)
private String occupation;

@ManyToOne
private TypeOfPatient typeOfPatient;

@ManyToOne
private User users;
   }

and the views :

  <div xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:field="urn:jsptagdir:/WEB-INF/tags/form/fields" xmlns:form="urn:jsptagdir:/WEB-INF/tags/form" xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:spring="http://www.springframework.org/tags" version="2.0">
<jsp:directive.page contentType="text/html;charset=UTF-8"/>
<jsp:output omit-xml-declaration="yes"/>
<form:create id="fc_com_simplemed_npc_domain_PatientDetails" modelAttribute="patientDetails" path="/patientdetailses" render="${empty dependencies}" z="8/olU0ivxZlcCzNCDYriOP+hE2U=">
    <field:input field="firstName" id="c_com_simplemed_npc_domain_PatientDetails_firstName" required="true" z="user-managed"/>
    <field:input field="lastName" id="c_com_simplemed_npc_domain_PatientDetails_lastName" required="true" z="user-managed"/>
    <field:input field="middleName" id="c_com_simplemed_npc_domain_PatientDetails_middleName" z="user-managed"/>
    <field:textarea field="address" id="c_com_simplemed_npc_domain_PatientDetails_address" required="true" z="0CYYBU4YKijB7hQ3Npq7QXHb2ys="/>
    <field:input field="city" id="c_com_simplemed_npc_domain_PatientDetails_city" required="true" z="pQoSTWOVKlwKWZV5OlKvsCwQt6M="/>
    <field:input field="province" id="c_com_simplemed_npc_domain_PatientDetails_province" required="true" z="7hzMJ6GrQfV6YMHTSNpUIw2z508="/>
    <field:input field="postalCode" id="c_com_simplemed_npc_domain_PatientDetails_postalCode" max="5" required="true" z="QttQ/Av8Y2LXLPjpc88NRqtu7kI="/>
    <field:input field="email" id="c_com_simplemed_npc_domain_PatientDetails_email" required="true" validationMessageCode="field_invalid_email" z="user-managed"/>
    <field:input field="homePhone" id="c_com_simplemed_npc_domain_PatientDetails_homePhone" max="12" z="pBKxDLFxHZKsvHUjMqozutbbkug="/>
    <field:input field="workPhone" id="c_com_simplemed_npc_domain_PatientDetails_workPhone" max="12" z="LViJ3WNDosJPBWk6AGJmcZrnjfw="/>
    <field:select field="sex" id="c_com_simplemed_npc_domain_PatientDetails_sex" items="${sexes}" path="sexes" required="true" z="OjuzCMOizRZlHrPGgWVrV6wnR0k="/>
    <field:datetime dateTimePattern="${patientDetails_dateofbirth_date_format}" field="dateOfBirth" id="c_com_simplemed_npc_domain_PatientDetails_dateOfBirth" past="true" required="true" z="tthi2TXacQkSlyRj+QX9HsbzaIs="/>
    <field:input field="socialSecurityName" id="c_com_simplemed_npc_domain_PatientDetails_socialSecurityName" max="10" required="true" z="lKuMt6y/W4VI1dJEiW3gk5ZvK3c="/>
    <field:textarea field="occupation" id="c_com_simplemed_npc_domain_PatientDetails_occupation" required="true" z="WfCTmH7Nkt3bMfkJ1HNpkqe+aa8="/>
    <field:select field="typeOfPatient" id="c_com_simplemed_npc_domain_PatientDetails_typeOfPatient" itemValue="id" itemLabel="patientTypeName" required="true" items="${typeOfPatients}" path="/typeofpatients" z="Uj2xfoaPX5/gkwXb9WBxdzAfN/4="/>
</form:create>
<form:dependency dependencies="${dependencies}" id="d_com_simplemed_npc_domain_PatientDetails" render="${not empty dependencies}" z="OEZW6AYtVJ5mEmMbn24lHjWtPp4="/>

I’m getting errors while submitting forms
enter image description here

Can anyone please help me on this…

Thanks in Advance.

Edit:

TypeOfPatient Class:

 public class TypeOfPatient {

@NotNull
private String patientTypeName;

@NotNull
@Size(max=1024)
private String decriptions;

@Override
public String toString() {
    return patientTypeName;
}

}

My Conversion Code :

  @Autowired
TypeOfPatientService typeOfPatientService;

public Converter<String, TypeOfPatient> getStringToTypeOfPatientConverter() {
    return new Converter<String, TypeOfPatient>() {
        @Override
        public TypeOfPatient convert(String id) {
            return typeOfPatientService.findTypeOfPatient(Long
                    .parseLong(id));
        }
    };
}
  • 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-11T06:07:40+00:00Added an answer on June 11, 2026 at 6:07 am

    You basically have to provide a Converter.

    EDIT:

    According to your comments you use <mvc:annotation-driven conversion-service="applicationConversionService"/>. If that’s something like this class, below code should work:

    public class ApplicationConversionServiceFactoryBean
        extends FormattingConversionServiceFactoryBean {
    
      @Autowired
      TypeOfPatientService typeOfPatientService;
    
      @Override
      protected void installFormatters(FormatterRegistry registry) {
        registry.addConverter(getStringToTypeOfPatientConverter());
        super.installFormatters(registry);
      }
    
      public Converter<String, TypeOfPatient> getStringToTypeOfPatientConverter() {
        return new Converter<String, TypeOfPatient>() {
          @Override
          public TypeOfPatient convert(String id) {
            return typeOfPatientService.findTypeOfPatient(Long.parseLong(id));
          }
        };
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple application using netbeans for developing and maven for building et
I'm building a simple web application in tornado.web using mongodb as the backend. 90%
I am building web application using Spring MVC Spring Security Hibenate MySQl I want
I'm building a simple web application that handles a simple database using struts and
I'm building simple dictionary application using WPF. I'm using MVVM pattern, databinding and FlowDocument
I am building a web application using Servlet 2.5, and I have encountered a
Here is my problem. I'm building a web application using MVC3 framework. My application
Im building simple family tree application and using Jung to draw the chart. So
I have a little (and stupid) problem: I'm building a PHP application using mysqli
I'm building a web application with Grails, using the Acegi/Spring Security plugin. I want

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.