Futurescale, Inc. PureMVC Home

The PureMVC Framework Code at the Speed of Thought


Over 10 years of community discussion and knowledge are maintained here as a read-only archive.

New discussions should be taken up in issues on the appropriate projects at https://github.com/PureMVC

Show Posts

* | |

  Show Posts
Pages: [1]
1  Announcements and General Discussion / Architecture / Re: AIR - Sqlite Proxy object on: August 01, 2008, 03:43:52
Yeah, you can actually pass an query / variables string to the delegates constructor.

Greets Thomas
2  Announcements and General Discussion / Architecture / Re: AIR - Sqlite Proxy object on: August 01, 2008, 02:22:53
hi neil,

if you take a look at my previous post ( the one with the loadPage example ) you can see, that "this" is passed to the constructor of the LocalDBDelegate as the "responder". As this class is probably a proxy that implements the interface, this is also the place ( with the onDelegateResult method), where the response is called by the Delegate.

Greets Thomas

3  Announcements and General Discussion / Architecture / Re: AIR - Sqlite Proxy object on: August 01, 2008, 12:25:36
Hi Neil,

call the static init() Method of the LocalDBDelegate class within the execute method your ModelPrepCommand or any other location prior to any db operationslike this:

:
var file:File = File.applicationStorageDirectory;
LocalDBDelegate.init( file );

greets
thomas
4  Announcements and General Discussion / Architecture / Re: AIR - Sqlite Proxy object on: July 31, 2008, 09:07:05
Hi Neil,

I usually put the Delegate Classes inside a "utility" package and import them to my project. Optionally, you can  leave them inside your applications model package for testing purposes. As long as your imports work, thats fine...

in order to make use of the LocalDBDelegate you need to:

1. implement the IDelegateResponder interface ( as you already did )
2. implement the 3 methods, the last 2 defined by the IDelegateResonder interface, similar to this

:
public function loadPage( id:int ):void
{
       new LocalDBDelegate( "CREATE TABLE 'users' .... ",  LocalDBDelegate.MODE_SYNC, this, null ).execute();
}

public function onDelegateResult( serviceid:String, data:Object ):void
{
    // this method is called by the Delegate after the query has been sucessfully executed
}

public function onDelegateFault( serviceid:String, data:Object ):void
{
   // this method is called by the Delegate, if the query has caused an error
}


Your code is probably only missing the "onDelegateFault" method as stated in the error message you received.
Do not forget to call the static "init()" method of the LocalDBDelegate class prior to any db operations.

Good luck ;)
Thomas
5  Announcements and General Discussion / Architecture / Re: AIR - Sqlite Proxy object on: July 31, 2008, 07:06:52
Hi Neil,

the LocalDBDelegate class (or any other delegate) can be used by any class that implements the IDelegateResponder interface.
In PureMVC AIR Projects I usually use them with Proxies in order to write in or retrieve data from the local SQLite DB.

If you dig into the framework at the moment, you might already know that Proxy Classes are generally used to manipulate and read from data entities (VOs). In case you want to retrieve or write from any other location than your programms memory, Delegates can come into play in order to handle more complex data oprations such as remote or local db calls. The key benefit of these "helper classes" is reusability, as you dont have to write db or remote code inside your proxy again and again.

I hope I could help...

Thomas



6  Announcements and General Discussion / Architecture / Re: AIR - Sqlite Proxy object on: April 29, 2008, 05:02:40
Hi,

I tried a different approach to access the local sqlLite DB from flex. Rather using proxies to handle my database logic, I let the the proxy only know little about the "service" and wrote the logic to a delegate. This way its easier to reuse the proxy and its logic if you want to exchange the "database service" to a "remoting service" for instance.

The implementation inside the proxy class then looks like this:
:

public class PageDataProxy extends Proxy implements IProxy, IDelegateResponder
{

.....

// service IDs
private static const _LOAD_PAGE:String = "loadPage";

.....

public function loadPage( id:int ):void
{
     // accessing a remote service
     new RemoteDelegate( "GetPageDocument", [id, ""], this, _LOAD_PAGE ).execute();
  
     // or optional

     // accessing a local database
     // new LocalDBDelegate( "SELECT * FROM....",  LocalDBDelegate.MODE_SYNC, this, _LOAD_PAGE ).execute();

}

public function onDelegateResult( serviceid:String, data:Object ):void
{
switch( serviceid )
{
case _LOAD_PAGE:

// parse xml page data to PageVO
parsePageData( data as XML );

// send notification
sendNotification( ApplicationFacade.PROXY_PAGE_LOADED );
break;
}
}

public function onDelegateFault( serviceid:String, data:Object ):void
{
     sendNotification( ApplicationFacade.PROXY_ERROR, serviceid );
}

.....


Please note, that the static LocalDBDelegate.init() method must be called before any DB operations. You can do this within the ModelPrepCommand or at any other point. See attachment for details.

Thomas

Pages: [1]