воскресенье, 30 декабря 2007 г.

DataServiceTransaction & LCDS

Just a quick blog note on something that I've now wasted a good day on twice, only because I never blogged it last time. The challenge is say you need to make changes to data in a database, maybe across multiple tables, and using DataServices just doesn't make sense. For example, cloning x number of records. It's easy enough to create your Java remote objects and call them from Flex, but then in an FDS/LCDS implementation how do you push those changes out to Flex clients?

There's some documentation on this, scattered vaguely across the web, and there's a good chance that perhaps this has already been blogged - but I just couldn't find it. The trick is that there are 2 sides to this story, one, you must perform your operations on the database directly, and then two, you must INFORM FDS that changes have occurred. So say I want to create a new Author record, this is what that might look like:
public void createAuthor(){ 
DataServiceTransaction dtx = DataServiceTransaction.begin(false);
//create record and save:
Author auth = new Author();
auth.setFirstName("Ernest");
auth.setLastName("Hemingway");
AuthorDAO dao = new AuthorDAO();
dao.create(auth);
//let LCDS know:
dtx.createItem("author", auth);
dtx.commit();
}
So I just do my regular db insert, then I use a DataServiceTransaction to let FDS know that I've created an Item. Alternatively, I could use this approach:
public void createFDSItem(){
DataServiceTransaction dtx = DataServiceTransaction.begin(false);
Author auth = new Author();
auth.setFirstName("victor");
auth.setLastName("javarubba");
AuthorDAO dao = new AuthorDAO();
dao.create(auth);
dtx.refreshFill("author", null);
dtx.commit();
}
This approach might be a bit of overkill and might be better suited when doing mass updates across many records. I did a little bit of testing and it seemed that for the most part calling CreateItem() was faster that the refreshFill() in pushing the new record to the Flex Client.

What cost me so much grief is that I was falsely led down the garden path to believe that calling dtx.createItem("author", auth) would not only inform FDS but also actually create the item. This is not the case. There! Officially blogged!

Flex and ApEx: exchanging data

Following my post Flex and Oracle, I wanted to investigate how difficult it would be to exchange data between flex and ApEx. After some trial and error I’m pleased to say that it isn’t that hard to exchange data between both technologies.

I started by looking for a way to get a simple string from a flex application to an ApEx application. I came across the ActionScript API "ExternalInterface". The Adobe documentation for the api:


The ExternalInterface class is the External API, an application programming interface that enables straightforward communication between ActionScript and the Flash Player container or a desktop application with Flash Player embedded.

ExternalInterface has a method "call" where you can specify the name of the external function you want to call, the second parameters are the parameters you want to pass to that function.



In your html page make a function called "setDept" with the necessary parameters and let the fill the Apex Items. Make a clickhandler in your flex application and call your function, you will see that it works perfect.

Now we have send data from flex to ApEx, it’s time to send something back from ApEx to flex. To start we need to be sure we have a JavaScript function that allows us to speak with the swf file. After some searching, trial and error, I came across the next function that works in both Mozilla and IE:



Now we need to create a javascript function that will pass a String to our flex application using the thisMovie function. Once this is done the only thing we need to create an ActionScript function that can registers an ActionScript method as callable from the container. We can use the method "callBack" from the "ExternalInterface" class for this.
Your Actionscript could look something like this:



Test the JavaScript function on your html page and you will see that you send data from your ApEx application to your flex application.



суббота, 29 декабря 2007 г.

DataServiceTransaction & LCDS

Just a quick blog note on something that I've now wasted a good day on twice, only because I never blogged it last time. The challenge is say you need to make changes to data in a database, maybe across multiple tables, and using DataServices just doesn't make sense. For example, cloning x number of records. It's easy enough to create your Java remote objects and call them from Flex, but then in an FDS/LCDS implementation how do you push those changes out to Flex clients?

There's some documentation on this, scattered vaguely across the web, and there's a good chance that perhaps this has already been blogged - but I just couldn't find it. The trick is that there are 2 sides to this story, one, you must perform your operations on the database directly, and then two, you must INFORM FDS that changes have occurred. So say I want to create a new Author record, this is what that might look like:
public void createAuthor(){ 
DataServiceTransaction dtx = DataServiceTransaction.begin(false);
//create record and save:
Author auth = new Author();
auth.setFirstName("Ernest");
auth.setLastName("Hemingway");
AuthorDAO dao = new AuthorDAO();
dao.create(auth);
//let LCDS know:
dtx.createItem("author", auth);
dtx.commit();
}
So I just do my regular db insert, then I use a DataServiceTransaction to let FDS know that I've created an Item. Alternatively, I could use this approach:
public void createFDSItem(){
DataServiceTransaction dtx = DataServiceTransaction.begin(false);
Author auth = new Author();
auth.setFirstName("victor");
auth.setLastName("javarubba");
AuthorDAO dao = new AuthorDAO();
dao.create(auth);
dtx.refreshFill("author", null);
dtx.commit();
}
This approach might be a bit of overkill and might be better suited when doing mass updates across many records. I did a little bit of testing and it seemed that for the most part calling CreateItem() was faster that the refreshFill() in pushing the new record to the Flex Client.

What cost me so much grief is that I was falsely led down the garden path to believe that calling dtx.createItem("author", auth) would not only inform FDS but also actually create the item. This is not the case. There! Officially blogged!

пятница, 28 декабря 2007 г.

Flex and ApEx: exchanging data

Following my post Flex and Oracle, I wanted to investigate how difficult it would be to exchange data between flex and ApEx. After some trial and error I’m pleased to say that it isn’t that hard to exchange data between both technologies.

I started by looking for a way to get a simple string from a flex application to an ApEx application. I came across the ActionScript API "ExternalInterface". The Adobe documentation for the api:


The ExternalInterface class is the External API, an application programming interface that enables straightforward communication between ActionScript and the Flash Player container or a desktop application with Flash Player embedded.

ExternalInterface has a method "call" where you can specify the name of the external function you want to call, the second parameters are the parameters you want to pass to that function.



In your html page make a function called "setDept" with the necessary parameters and let the fill the Apex Items. Make a clickhandler in your flex application and call your function, you will see that it works perfect.

Now we have send data from flex to ApEx, it’s time to send something back from ApEx to flex. To start we need to be sure we have a JavaScript function that allows us to speak with the swf file. After some searching, trial and error, I came across the next function that works in both Mozilla and IE:



Now we need to create a javascript function that will pass a String to our flex application using the thisMovie function. Once this is done the only thing we need to create an ActionScript function that can registers an ActionScript method as callable from the container. We can use the method "callBack" from the "ExternalInterface" class for this.
Your Actionscript could look something like this:



Test the JavaScript function on your html page and you will see that you send data from your ApEx application to your flex application.



DataServiceTransaction & LCDS

Just a quick blog note on something that I've now wasted a good day on twice, only because I never blogged it last time. The challenge is say you need to make changes to data in a database, maybe across multiple tables, and using DataServices just doesn't make sense. For example, cloning x number of records. It's easy enough to create your Java remote objects and call them from Flex, but then in an FDS/LCDS implementation how do you push those changes out to Flex clients?

There's some documentation on this, scattered vaguely across the web, and there's a good chance that perhaps this has already been blogged - but I just couldn't find it. The trick is that there are 2 sides to this story, one, you must perform your operations on the database directly, and then two, you must INFORM FDS that changes have occurred. So say I want to create a new Author record, this is what that might look like:
public void createAuthor(){ 
DataServiceTransaction dtx = DataServiceTransaction.begin(false);
//create record and save:
Author auth = new Author();
auth.setFirstName("Ernest");
auth.setLastName("Hemingway");
AuthorDAO dao = new AuthorDAO();
dao.create(auth);
//let LCDS know:
dtx.createItem("author", auth);
dtx.commit();
}
So I just do my regular db insert, then I use a DataServiceTransaction to let FDS know that I've created an Item. Alternatively, I could use this approach:
public void createFDSItem(){
DataServiceTransaction dtx = DataServiceTransaction.begin(false);
Author auth = new Author();
auth.setFirstName("victor");
auth.setLastName("javarubba");
AuthorDAO dao = new AuthorDAO();
dao.create(auth);
dtx.refreshFill("author", null);
dtx.commit();
}
This approach might be a bit of overkill and might be better suited when doing mass updates across many records. I did a little bit of testing and it seemed that for the most part calling CreateItem() was faster that the refreshFill() in pushing the new record to the Flex Client.

What cost me so much grief is that I was falsely led down the garden path to believe that calling dtx.createItem("author", auth) would not only inform FDS but also actually create the item. This is not the case. There! Officially blogged!

среда, 26 декабря 2007 г.

DataServiceTransaction & LCDS

Just a quick blog note on something that I've now wasted a good day on twice, only because I never blogged it last time. The challenge is say you need to make changes to data in a database, maybe across multiple tables, and using DataServices just doesn't make sense. For example, cloning x number of records. It's easy enough to create your Java remote objects and call them from Flex, but then in an FDS/LCDS implementation how do you push those changes out to Flex clients?

There's some documentation on this, scattered vaguely across the web, and there's a good chance that perhaps this has already been blogged - but I just couldn't find it. The trick is that there are 2 sides to this story, one, you must perform your operations on the database directly, and then two, you must INFORM FDS that changes have occurred. So say I want to create a new Author record, this is what that might look like:
public void createAuthor(){ 
DataServiceTransaction dtx = DataServiceTransaction.begin(false);
//create record and save:
Author auth = new Author();
auth.setFirstName("Ernest");
auth.setLastName("Hemingway");
AuthorDAO dao = new AuthorDAO();
dao.create(auth);
//let LCDS know:
dtx.createItem("author", auth);
dtx.commit();
}
So I just do my regular db insert, then I use a DataServiceTransaction to let FDS know that I've created an Item. Alternatively, I could use this approach:
public void createFDSItem(){
DataServiceTransaction dtx = DataServiceTransaction.begin(false);
Author auth = new Author();
auth.setFirstName("victor");
auth.setLastName("javarubba");
AuthorDAO dao = new AuthorDAO();
dao.create(auth);
dtx.refreshFill("author", null);
dtx.commit();
}
This approach might be a bit of overkill and might be better suited when doing mass updates across many records. I did a little bit of testing and it seemed that for the most part calling CreateItem() was faster that the refreshFill() in pushing the new record to the Flex Client.

What cost me so much grief is that I was falsely led down the garden path to believe that calling dtx.createItem("author", auth) would not only inform FDS but also actually create the item. This is not the case. There! Officially blogged!

вторник, 25 декабря 2007 г.

Flex and ApEx: exchanging data

Following my post Flex and Oracle, I wanted to investigate how difficult it would be to exchange data between flex and ApEx. After some trial and error I’m pleased to say that it isn’t that hard to exchange data between both technologies.

I started by looking for a way to get a simple string from a flex application to an ApEx application. I came across the ActionScript API "ExternalInterface". The Adobe documentation for the api:


The ExternalInterface class is the External API, an application programming interface that enables straightforward communication between ActionScript and the Flash Player container or a desktop application with Flash Player embedded.

ExternalInterface has a method "call" where you can specify the name of the external function you want to call, the second parameters are the parameters you want to pass to that function.



In your html page make a function called "setDept" with the necessary parameters and let the fill the Apex Items. Make a clickhandler in your flex application and call your function, you will see that it works perfect.

Now we have send data from flex to ApEx, it’s time to send something back from ApEx to flex. To start we need to be sure we have a JavaScript function that allows us to speak with the swf file. After some searching, trial and error, I came across the next function that works in both Mozilla and IE:



Now we need to create a javascript function that will pass a String to our flex application using the thisMovie function. Once this is done the only thing we need to create an ActionScript function that can registers an ActionScript method as callable from the container. We can use the method "callBack" from the "ExternalInterface" class for this.
Your Actionscript could look something like this:



Test the JavaScript function on your html page and you will see that you send data from your ApEx application to your flex application.