Grails: интеграция базового веб-приложения Java (Spring + Hibernate): подобъект не отображает свои поля в форме - PullRequest
0 голосов
/ 19 марта 2012

Проблема в том, что мои классы POJO / Domain находятся в java (на самом деле это очевидно, но только для ясности), используемый мной подобъект не отображается должным образом в форме, когда я нажимаю на доступные контроллеры: Например: У пациента есть адрес - >> адрес - это подобъект пациента: Поле адреса показывает пустой выпадающий список. Как мне решить это? Я использую def scaffold = в контроллере.

 package pojo;

public class Address {

private int id;
private String street;
private String city;
private String state;
private String country;
private Integer clinicid;
private Integer patientid;

public Address(){
super();
}


public int getId() {
return id;
}


public void setId(int id) {
this.id = id;
}


public String getStreet() {
return street;
}


public void setStreet(String street) {
this.street = street;
}


public String getCity() {
return city;
}


public void setCity(String city) {
this.city = city;
}


public String getState() {
return state;
}


public void setState(String state) {
this.state = state;
}


public String getCountry() {
return country;
}


public void setCountry(String country) {
this.country = country;
}

public Integer getClinicid() {
return clinicid;
}


public void setClinicid(Integer clinicid) {
this.clinicid = clinicid;
}


public Integer getPatientid() {
return patientid;
}


public void setPatientid(Integer patientid) {
this.patientid = patientid;
}

}


package pojo;


public class Clinic  {


private int  id ;     
private String clinicname ;
private Address address;
public int contactNumber;



public Clinic() {
address=new Address();
}

public int getId() {
return id;
}



public void setId(int id) {
this.id = id;
}



public String getClinicname() {
return clinicname;
}



public void setClinicname(String clinicname) {
this.clinicname = clinicname;
}



public Address getAddress() {
return address;
}



public void setAddress(Address address) {
address.setClinicid(this.id);
this.address = address;
}



public int getContactNumber() {
return contactNumber;
}



public void setContactNumber(int contactNumber) {
this.contactNumber = contactNumber;
} }




package pojo;

import java.util.*;

public class Doctor {

private int id      ;
private Date dateOfBirth  ;
private String username; 
private String password ; 
//private String name  ;
private int contactNumber ;
private String specialization ;
public Clinic clinic;


public Doctor(){
clinic=new Clinic();
}

public Clinic getClinic() {
return clinic;
}
public void setClinic(Clinic clinic) {
this.clinic = clinic;
}

/*public Doctor() {

}*/
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public Date getDateOfBirth() {
return dateOfBirth;
}
 public void setDateOfBirth(Date dateOfBirth) {
   this.dateOfBirth = dateOfBirth;
}
public String getUsername() {
return username;
}
 public void setUsername(String username) {
this.username = username;
}
 public String getPassword() {
 return password;
}
public void setPassword(String password) {
this.password = password;
}

public int getContactNumber() {
return contactNumber;
}
public void setContactNumber(int contactNumber) {
this.contactNumber = contactNumber;
}
public String getSpecialization() {
return specialization;
}
public void setSpecialization(String specialization) {
this.specialization = specialization;
}
}




package pojo;
import java.util.*;
public class Patient  {

private int id;
private Date dateOfBirth;
private Date registrationDate;
private String name ;
public int contactNumber; 
public  enum sexenum {MALE, FEMALE}
public sexenum sex;
private Address address;
private Clinic clinic;
private Doctor doctor;

public Patient(){
clinic=new Clinic();
doctor=new Doctor();
}

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}
public Date getDateOfBirth() {
return dateOfBirth;
}
public void setDateOfBirth(Date dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}
public Date getRegistrationDate() {
return registrationDate;
}
public void setRegistrationDate(Date registrationDate) {
 this.registrationDate = registrationDate;
 }

public String getName() {
return name;
 }

 public void setName(String name) {
 this.name = name;
  }

 public int getContactNumber() {
 return contactNumber;
 }

  public void setContactNumber(int contactNumber) {
  this.contactNumber = contactNumber;
  }

 public sexenum getSex() {
 return sex;
 }

 public void setSex(sexenum sex) {
 this.sex = sex;
  }

 public Address getAddress() {
 return address;
 }

 public void setAddress(Address address) {
 address.setPatientid(this.id);
 this.address = address;
 }

 public Clinic getClinic() {
 return clinic;
}

 public void setClinic(Clinic clinic) {
 this.clinic = clinic;
  }

 public Doctor getDoctor() {
  return doctor;
   }

  public void setDoctor(Doctor doctor) {
  this.doctor = doctor;
   }


    } 

 patient [ one to one with ] address;.
clinic [ one to one with ] address;.
doctorid [ foreign key  many to one]where ever referenced.
clinic id [foreign key many to one ] where ever referenced.

1 Ответ

0 голосов
/ 20 марта 2012

Насколько я знаю, Grails поддерживает только отображения GORM (http://grails.org/doc/latest/guide/single.html#ormdsl) и отображения гибернации (http://grails.org/doc/latest/guide/single.html#hibernate)

).

Я не думаю, что предоставленные вами сопоставления действительны для строительных лесов.

...