Backendless事件不会发生

时间:2016-03-15 21:07:46

标签: java android events backendless

在我的Android应用中,我使用Backendless在线存储我的数据。我想在保存新的Point对象时执行某些操作,但beforeCreate事件永远不会被触发。

Bootstrap.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;
    }
}

BackendlessObject.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();

1 个答案:

答案 0 :(得分:1)

这已在最新版本的库中修复。请务必从github repository获取副本。