I'm running smartgwtee-2.3 with GAE 1.3.6 and trying to get a couple of data sources set up. I'm using com.isomorphic.jpa.GAEJPADataSource as the data store.
I'm just trying to get a simple ListGrid set up with this data. The problem seems to be that DataSource.get("course_DataSource") is returning null. Is there a way to get an error code or otherwise find out WHY it's returning null?
I'm translating this code almost directly from the country and city example included (ds-gae). I've probably missed some bit of the translation. Are there any small things that are easy to forget about setting up DataSources?
Thanks ~
Here's my code for the entry point:
Here's course_DataSource.ds.xml:
and here's Course.Java
standard_DataSource.ds.xml
Standard.Java:
The exception:
I'm just trying to get a simple ListGrid set up with this data. The problem seems to be that DataSource.get("course_DataSource") is returning null. Is there a way to get an error code or otherwise find out WHY it's returning null?
I'm translating this code almost directly from the country and city example included (ds-gae). I've probably missed some bit of the translation. Are there any small things that are easy to forget about setting up DataSources?
Thanks ~
Here's my code for the entry point:
Code:
public void onModuleLoad()
{
final DataSource standardDS = DataSource.getDataSource("course_DataSource");
final ListGrid lg = new ListGrid();
lg.setDataSource(standardDS);
lg.draw();
IButton addButton = new IButton("Add a record");
addButton.addClickHandler(new com.smartgwt.client.widgets.events.ClickHandler() {
@Override
public void onClick(
com.smartgwt.client.widgets.events.ClickEvent event)
{
lg.startEditingNew();
}
});
addButton.draw();
}
Code:
<DataSource
ID="course_DataSource"
serverConstructor="com.isomorphic.jpa.GAEJPADataSource"
beanClassName="com.longfellow.egmockup.server.Course"
>
<fields>
<field name="courseID" type="text" hidden="true" primaryKey="true" />
<field name="courseName" type="text" title="Course Title" required="true" />
<field name="standards" type="standard_DataSource" title="Standards" multiple="true"
javaClass="com.longfellow.egmockup.server.Standard"/>
</fields>
</DataSource>
Code:
package com.longfellow.egmockup.server;
import java.io.Serializable;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import org.datanucleus.jpa.annotations.Extension;
@Entity
public class Course implements Serializable
{
@Id
@Column (nullable = false)
@GeneratedValue (strategy = GenerationType.IDENTITY)
@Extension (vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
private String courseID;
@Column (nullable = false)
private String courseName;
@OneToMany (cascade=CascadeType.ALL)
private List<Standard> standards;
public Course()
{
standards = new ArrayList<Standard>();
}
public String getCourseID()
{
return courseID;
}
public void setCourseID(String courseID)
{
this.courseID = courseID;
}
public String getCourseName()
{
return courseName;
}
public void setCourseName(String cn)
{
courseName = cn;
}
public List<Standard> getStandards()
{
return standards;
}
public void setStandards(List<Standard> stds)
{
standards = stds;
}
/**
* Returns a string representation of the object. Resulting string contains
* full name of the class and list of its properties and their values.
*
* @return <code>String</code> representation of this object.
*/
@Override
public String toString ()
{
return getClass().getName()
+ "["
+ "courseID=" + ((getCourseID() == null) ? "null" : getCourseID().toString())
+ ", "
+ "courseName=" + ((getCourseName() == null) ? "null" : getCourseName().toString())
+ "]";
}
}
Code:
<DataSource
ID="standard_DataSource"
serverConstructor="com.isomorphic.jpa.GAEJPADataSource"
beanClassName="com.longfellow.egmockup.server.Standard"
>
<fields>
<field name="standardID" type="text" hidden="true" primaryKey="true" />
<field name="standardName" type="text" title="Standard Name" required="true" />
<field name="courseID" type="text" title="Course" canEdit="false"
foreignKey="course_DataSource.courseID"/>
</fields>
</DataSource>
Code:
package com.longfellow.egmockup.server;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import org.datanucleus.jpa.annotations.Extension;
@Entity
public class Standard implements Serializable
{
@Id
@Column (nullable = false)
@GeneratedValue (strategy = GenerationType.IDENTITY)
@Extension (vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
private String standardID;
@Column (nullable = false)
private String standardName;
@Column (nullable = false)
@Extension (vendorName = "datanucleus", key = "gae.parent-pk", value = "true")
private String courseID;
@ManyToOne (fetch=FetchType.LAZY)
private Course course;
public Standard ()
{
}
public String getStandardID()
{
return standardID;
}
public void setStandardID (String standardID)
{
this.standardID = standardID;
}
public String getStandardName ()
{
return standardName;
}
public void setStandardName (String standardName)
{
this.standardName= standardName;
}
public String getCourseID()
{
return courseID;
}
public void setCourseID (String courseID)
{
this.courseID= courseID;
}
public Course getCourse() {
return course;
}
public void setCourse(Course course) {
this.course = course;
}
/**
* Returns a string representation of the object. Resulting string contains
* full name of the class and list of its properties and their values.
*
* @return <code>String</code> representation of this object.
*/
@Override
public String toString ()
{
return getClass().getName()
+ "["
+ "standardID=" + ((getStandardID() == null) ? "null" : getStandardID().toString())
+ ", "
+ "cityName=" + ((getStandardName() == null) ? "null" : getStandardName().toString())
+ "]";
}
}
Code:
java.lang.NullPointerException: null
at com.smartgwt.client.widgets.grid.ListGrid.setDataSource(ListGrid.java:11390)
at com.longfellow.egmockup.client.EmpoweringGradesMockup.onModuleLoad(EmpoweringGradesMockup.java:48)
...
Comment