0

在我的 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();
4

1 回答 1

1

这已在最新版本的库中得到修复。确保从github 存储库中获取一份副本。

于 2016-03-16T08:17:09.260 回答