Donnerstag, 10. Juli 2008

Grails, Flex, Soap

Today I have written a small PoC for Grails, Flex, SOAP. The initial task was (and still is) to find out which communication takes place in a Flex application.

Having no clue about Flex, a little understandig of Web Services and some minor understanding of Grails, it took me no more than 3 hours, including googling for web service usage in Flex and hunting of really stupid beginners bug.

This shows the real muscles of Grails and its really awesome plugin ecosystem.


grails create-app HelloFlex
cd HelloFlex
grails install-plugin flex
grails install-plugin xfire
grails create-service hello

Ok, everything needed is installed. 2 more things to do. in HelloFlex\services\HelloService.groovy:

class HelloService {
static expose=['xfire', 'flex-remoting']
def hello(String echo) { return echo.reverse() }
}


Note the use of expose: this service is both available via flex-remoting and via SOAP.

Second: create HelloFlex\web-app\test.mxml


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:WebService
id="userRequest"
wsdl="http://localhost:8080/HelloFlex/services/hello?wsdl">
<mx:operation name="hello" resultFormat="object"
fault="mx.controls.Alert.show(event.fault.faultString)"
result="showResult(event)"/>
</mx:WebService>
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import mx.rpc.events.FaultEvent;
import mx.controls.Alert;
[Bindable] private var passage:String;
private var options:Object = {"output-format": "plain-text"};
private function showResult(e:ResultEvent):void {
passage = userRequest.hello.lastResult;
}
private function send_data(input:String):void {
userRequest.hello(input);
}
]]>
</mx:Script>

<mx:Text text="Echo Service" fontSize="16" fontWeight="bold"/>
<mx:Text text="Input" fontSize="12"/>
<mx:TextInput id="lookupPsg" textAlign="center"/>
<mx:Button label="Submit" click="send_data(lookupPsg.text)"/>
<mx:TextArea height="352" width="590" id="psg" text="{passage}" editable="false" fontSize="11"/>
</mx:Application>

(sorry for the mess, dunno how to format this better )

Hitting http://localhost:8080/HelloFlex/test.mxml displays the Flex application which uses SOAP protocol to consume the webservice.

Built on the shoulder of giants...

Update 12th Jul: Marcel Overdijk has already written a similar (well, actually better:)) example back in january.

Montag, 7. Juli 2008

Complex Swing Widgets, where art thou?

I am currently looking at creating something with a good ol' Swing interface.

A typical use case is the following scenario: a drag-and-droppable, sortable, pageable treetable with editable fields. Datatype aware editors, subtrees, master-detail views would be considered as added value. Such a treetable always

I did find the respective contributions of ext-js and jquery quite usable, albeit both need some customizing and/or (more or less) programming.

Coming back to Swing after several years, I naively expected to have a plethora of tree table implementations. Well, at the moment the only thing I have found is the SwingX Treetable. I will have a look at it in near future.

The question I ask myself is wether the HTML/js way is the way to go also for complex GUIs? I would still think that this platform has its limitations. But when I do see how sparse complex Swing widgets are, I really am unsure to use the right technology. Also things like autocompletion and other Web2.0 goodies should be easily available.

What is your opinion? Are there other Swing (or SWT, whatever) widgets collections with advanced components available? Does the Flex ecosystem provide more components?

update 9th Jul
Well, I guess I was right with not finding a Swing TreeTable: others have been waiting for it, too...