在我的 Android 应用程序中,我使用Backendless在线存储我的数据。Point
我想在保存新对象但beforeCreate
事件永远不会被触发时做一些事情。
引导程序.java
public class Bootstrap implements IBackendlessBootstrap
{
@Override
public void onStart()
{
Backendless.setUrl( "https://api.backendless.com" );
Backendless.initApp( "XXXXXXXXXXXXXXXX", "XXXXXXXXXXXXX","v1");
Backendless.Persistence.mapTableToClass( "Point", Point.class );
}
@Override
public void onStop()
{
}
}
PointTableEventHandler.java:
@Asset( "Point" )
public class PointTableEventHandler extends com.backendless.servercode.extension.PersistenceExtender<Point>
{
@Override
public void beforeCreate( RunnerContext context, Point point) throws Exception
{
System.out.println("enter beforeCreate");
point.setPhoneNumber("12345");
System.out.println("exit beforeCreate");
}
}
Point.java
public class Point extends BackendLessObject {
private String phoneNumber;
public Point() {
super();
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
}
后端无对象.java
public class BackendLessObject {
protected String objectId;
protected Date created;
protected Date updated;
protected String ownerId;
public BackendLessObject() {
}
public String getObjectId() {
return objectId;
}
public void setObjectId( String objectId )
{
this.objectId = objectId;
}
public Date getCreated()
{
return created;
}
public void setCreated( Date created )
{
this.created = created;
}
public Date getUpdated()
{
return updated;
}
public void setUpdated( Date updated )
{
this.updated = updated;
}
public String getOwnerId() {
return ownerId;
}
@Override
public String toString() {
return objectId;
}
}
该事件已启用并部署到生产环境。当我运行我的应用程序时,该点是使用提供的所有数据创建的,但未PhoneNumber
设置 - 所以事件没有运行。调试它也表明它从未被调用过。
在我的 Android 应用程序中,我调用
newPoint.save();