Monday, July 14, 2008

ESB in silo-silo apps?

Tom Baeyens posted a great blog entry in terms of data services, most specifically Business Process, in an SOA. As he said:

"The main point I have tried to make is that the implementation of Business Processes should not be tied to integration technologies (read: the ESB). They can be just as well located within the application silos."


So from here i want to extend it into a silo applications scenario. For example, suppose we have 3 Java applications that working as their own. Obviously there is no need to implement any kind of ESB+BPEL "interface" to connect them together -- we can easily take advantage of jPDL or JPD or any other "tight coupled" Java Business Process solution(s) in this specific envionrnment. For the future's perspective, its definitely better to connect these apps by ESB(s) via messaging technologies. However, I get confused about BPEL that whether this language is a "tightly-coupled" language for ESB only?

Where does BPEL belong to? In ESB only?

Wednesday, July 9, 2008

Generate PDF from Flex Application by AlivePDF

Another story about Flex. Now this one is about using AlivePDF to generate PDF file from Flex Application. Its actually very funny that Flex and PDF are both Adobe's products but integrating them together is not that easy (at least there is no existing easy+free solution).

Lets look at what AlivePDF offers. This excellent open-source project is also available at Google Code. Note, generating PDF from AIR application is a little bit different (actually easier). Consult AlivePDF for more details.

In order to generate PDF rather than simply print it to a paper, firstly create a PDF function in MXML script block:
... ...
private function doPrintPDF():void {
var myPDF:PDF = new PDF(Orientation.PORTRAIT,
Unit.MM, Size.A4 );
myPDF.setDisplayMode(Display.FULL_PAGE,
Layout.SINGLE_PAGE );
myPDF.addPage();
myPDF.addImage(this.Template_box, 5, 5, 0, 0,
ImageFormat.JPG, 100, 1, ResizeMode.FIT_TO_PAGE,
"Normal", true);

myPDF.save(Method.REMOTE, "http://localhost/create.php",
Download.ATTACHMENT, "my_flash.pdf");
}
  1. at first create a PDF class which will initialize the required resources for generating a PDF. For example, page size here is A4, and page is portrait.
  2. next you define the page layout settings, very straightforward
  3. after all of these, you can call addPage() to add a page into your myPDF. Remember, you must "add a page" before adding any contents
  4. ok now i have a page already, but its empty. Next, call addImage() to add content into my page. The beauty of addImage() is you can add Flex Display Object into your page. For example, here i "print" my VBox and all its children. Be careful of the numbers: 5, 5, 0, 0. First 5 and 5 mean your "image" will be added 5 pixies after the top-left corner of paper (A4 here). Next 0 and 0 are very tricky. They means "shirk" my image if its too big (bigger than A4 here) or keep it normal when the size is equal or less that the paper (A4 again). Also you can define customized size of your image, for example, 5, 5, 200, 100 means print my image at 5 pixies and image size is 200, 100, regardless of its original size.
  5. save it. Remember you must provide the correct location of your create.php file (simply copy paste it to your_root/Sites if you are using Mac). As for the current time being that Flash player requires server script support for downloading files, you must provide this file when user want to save it to their local machine. On the other hand, use Method.Local for AIR application as it supports local file streams naturally.
Already, all we need is done. Next in your application, add a button as:

< label="Print PDF" click="doPrintPDF()">

That's it. Oh BTW, gonna say sorry to AlivePDF's author Thibault Imbert that i have created a bug report in Google Code but that i didn't realize that providing 0 and 0 in addImage() will "shirk" the image automatically. Well actually i found this from the source code, but anyway, its great that i dont have to write my own ratio calculation function. :)

Monday, July 7, 2008

A simple Flex print button

Recently i am working on a Flex project that i have created a simple print button in order to simply print my flash movie into one single A4 paper. It sounds interesting at first coz no one would think about to print a "moving" picture. However as the project requests, i have to make this possible and make it as simple as possible.

Straight to the code. Firstly i create a simple "PrintButton" that extends the existing UI button and also with a printing function.


package jiang.example {
import flash.events.MouseEvent;
import mx.controls.Button;
import mx.core.UIComponent;
import mx.printing.FlexPrintJob;
import mx.printing.FlexPrintJobScaleType;

public class PrintButton extends Button {
//component attributes
public var component:UIComponent;
public var paper:String;

public function PrintButton():void {
super();
addEventListener(MouseEvent.CLICK, printJobInvocation);
}

// Define private click event handler.
private function printJobInvocation(event:MouseEvent):void {
var printJob:FlexPrintJob = new FlexPrintJob();

//Start the print job
if (printJob.start() != true) return;

if(paper == "OnePage") {
printJob.addObject(component,
FlexPrintJobScaleType.SHOW_ALL);
}
else if(paper == "FillPage") {
printJob.addObject(component,
FlexPrintJobScaleType.FILL_PAGE);
}
else if(paper == "MatchHeight") {
printJob.addObject(component,
FlexPrintJobScaleType.MATCH_HEIGHT);
}
else if(paper == "MatchWidth") {
printJob.addObject(component,
FlexPrintJobScaleType.MATCH_WIDTH);
}
else if(paper == "None") {
printJob.addObject(component,
FlexPrintJobScaleType.NONE);
}
//default print paper setting
else {
printJob.addObject(component,
FlexPrintJobScaleType.SHOW_ALL);
}

//output to hardware
printJob.send();
}
}
}


This simple class can be compiled in both Flex 2 and 3. Put it into the right folder. Next in my simple MXML application,


<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
xmlns:="jiang.example.*"
backgroundGradientColors="[#ffffff, #ffffff]"
backgroundColor="#FFFFFF">
<mx:VBox>
<mx:VBox id="Template_box" verticalGap="0" ...>
... ... ...
</mx:VBox>
<mx:Spacer height="15"/>
<PrintButton component="{this.Template_box}"
label="Print" borderColor="#000000" fillAlphas="[1.0, 1.0]"
fillColors="[#FFFFFF, #FFFFFF, #FFFFFF, #D6F5D1]"/>
</mx:VBox>
</mx:Application>

Remember one thing before you try this little application. Click Flex's "Project" in the menu bar, and then "Properties", and then click "Flex Compiler" in the left-hand menu, add -default-background-color #FFFFFF (look out the space) to the compiler arguments. This argument will set the application's default color from haloblue to white. Also notice that i have used backgroundColor="#FFFFFF" in my Application tag, this one also helps me to change the default color to white.

Turn back to my PrintButton tag, it takes two cousmized attributes:
  1. component: takes any UIComponent that you want to print, e.g. VBox, button, textarea etc.
  2. paper: tell printer how you want to print it, in one page, multiple page?
My upper example print the "Template_box" component and all its children and it print all of them in one paper (shirk it if its too large). This button can also works with dynamic contents: it will print whatever Template_box has in the screen when you click it. So if your mxml has some runtime WYSIWYG functions, it also works.

However, i found a very annoy problem: the damn halo blue color. I have to set up all parent Boxes to have backgroudcolor = #FFFFFF, otherwise it will print halo blue as the default background color for Box component. I hope i can find an easy and possible solution for this soon.

Thursday, July 3, 2008

Google gets serious about Open social

Just looked at Google code and found this new project called "Google Friend Connect". Lets see what it can do.

Unfortunately i have been to Google DeveloperDay at Sydney this year but unable to attend the open-social speech. I am not sure how serious Google is on this topic since we have so many successful stories already, e.g. MySpace and Facebook. As a result, i didn't see any point that Google shows endeavor in this area.

However, read a tech story today states that Google plans to propose its iGoogle as a future "HUB" for global users (i bet its functionality is more or less similar to MySpace or Facebook, or even MSN space). As it says, currently gmail "traps" more attentions than any other google products. Therefore as an improvement, Google plans this "Canvas" API for its open-social platform to try to attract as many developers as they can to enrich its current Web content and experience.

I have no interest in terms of this "social function" provided by Google since i use Facebook everyday. It may be soon "fully occupied" by developers, who knows.

Tuesday, July 1, 2008

iPhone3 == 3xiPhone

Finally as we saw, Telstra joined the mess. According to the unreleased plan,
$279 for an 8GB iPhone 3G or $399 for the 16GB version.
Good news isn't it? Hold on, check out the next line:
while subscribers can obtain the 8GB phone for free with an $80 monthly plan and the 16GB handset for free with a $100 plan.
What the hell! I dare to ask who the hell wants to pay $1920 for just a single bloody mobile phone!? Have a look on the street, those old-timers are still holding a 10-years-old Nokia for just simple telephone and SMS. This price is unbelievable; i can almost buy a MBP by this price.

In fact, i use MBP for my job and daily life; i listen to my nano wherever i been but i gonna say i am not a (huge) Apple fan, neither a windows fan :). The only reason i use Mac OS is because windows sucks and Linux has fairly limited supported software (espacially in enterprise environment). To be honest, i believe Apple products are over-priced. Yes, they do provide high quality, but that's not mean we are fool. Check out the new iPhone 3G plan all over the world:
  • In Canada, FIDO & ROGERS, the lowest price is $60/month and the highest is $115/month. Most importantly, the $115 package can only use 2G for data transfer, and the funny thing is, they explain that 2G equals to 1 million text messages or 16,000 web pages. F**k you fool, it has the bloody Wi-Fi builted in, what the point of having 1M text msgs? I can just pay $39 from Vodafone for 5G mobile internet.
  • 3G at HongKong, 8G version costs $120 with the $42/month plan, and 16G version costs $223 with $34/month plan. Cheaper isn't? If i really want to buy one, it will definitely be HK.
  • America, oh i love it. You just need to pay $30/month for single customer or $40/month or enterprise.
Now Jobs' $199 joke is over. As the concurrency is almost the same between Aus $ and US $, i dont see the point that why Australian have to pay almost $1000 extra dollars for it. It doesn't have Flash support; it doesnt have video call and it does have Wi-Fi builted-in but most companies are selling their Wi-Fi servers rather than telling you that this small brillent device can connect to your wireless router at your home or office.

I am pretty angre with the price, meanwhile i am downloading the damn 1.2G iPhone SDK. Holy shit, can you just make it smaller Jobs? I gonna pay my bill next month, not you!!

Monday, June 30, 2008

A sample Google Flash Map App

Well what a boring Monday afternoon. Luckily i remembered my unfinished Google map toy and created a sample fun application, deployed at my website. Here is the sample screen shot:

Friday, June 27, 2008

Pilot

Keep google products with my gmail account.