Feeds:
Posts
Comments

Recently I got a job to work for a company that makes apps for social network photo printing  call hotprints.. I dusted off the 2 applications I wrote to be run in facebook nearly 4 years  ago to remind myslef what I done and get reacquainted with my virtual social well being. I see how much  facebook have moved on with their platform, now they have theses things call ‘pages’ which is place where you can place your company mark on to the site. Members can become a fan and with the ability to add application to as tabs in the pages. Companies can relay on other company to increase exposure.. That all great but what does that meant to me as a web users?

I think this could fundamentally change our way of doing web search. Not only can I search for the things I am interested from something like google (gosh that so last year!) and gives me specific results of things that I can think of,  but I could potentially get more accurate result base on my social graph even suggest related issues that I didn’t think of. Bing.com says it can also share its searches to facebook.. I definitely want to have a go and see what I can do with the FB social graph and the pages integration to automatically gain a better understanding of my search preferences..

The GWT grails plugin is great. I really like GWT and what it can do, plus the promise of Wave integration on both client and appengine should present some interesting possibilities. Working with grails is a breeze once there is a understanding of how it works setting up a site is fast fast fast :)

So I been working on using grails, appengine, GWT to work together.. This is what I done:

  • create a grails app as normal ‘grails create-app’
  • installed the plugins I want. ‘grails install-plugin GWT’ + ‘grails install-plugin app-engine’
  • write my GWT client as I would do in Java (under src/gwt). Setting up the Service Interfaces etc.
  • created a grails service to act as my GWT servlet as suggested (this bit i love as I don’t need to edit my web.xml)
  • create the html page ‘grails create-gwt-page <page>.html <module>
  • run the application using ‘grails app-engine run’ (this bit works well too as it invokes the gwt complier, compiles my GWT app and places all files in the right place.. sweet..)
  • run the Hosted client ‘grails run-gwt-client’ expecting things will slot in place
  • Doesn’t work :(

A few of things I noticed:

  • When doing ‘grails app-engine run’ (which will try to compile your GWT app) the gwt compiler compiles the application that sits under src/gwt but the classes do not get added to the classpath (the classes don’t get put into the classes dir) as grails only puts the classes in src/java. So when you use a GWT component the app blows up. By making sure classes under src/gwt gets compiled in grails solves the problem.
  • When creating the html page if you don’t add a sub directory as part of the page creation the gwt gets confuse with rpc calls.
  • Also the html page needs to be added into web.xml under src/templates/war as welcome-file-list tag like in a java base GWT application. If it don’t exist use ‘grails install-templates’
  • Finally if you include other GWT modules as jars (such as gwtext) it needs to be added to your classpath manually. When using ‘grails compile-gwt-modules’ the script looks into lib/gwt and add the jars to classpath but if you action ‘grails app-engine run’ it doesn’t look into lib/gwt (or gets overridden) tho it does invoke the gwt compiler.

After doing this I have managed to login using the google’s appengine API and displays my app which is using gwtext.

Trying to use maven2 and google eclipse plugin (for appengine and GWT) can be a little tricky. As the plugin insist to create a project structure that is not very maven like. The problem is in the ‘war’ dir that is created under ${basedir}, maven need it to be in under src/main/webapp, if you force the change (i.e. drag and drop) eclipse complain and will not run finally the plugin do not allow you reconfig.

But I would still like to use all the cool integrated feature that the plugin offers with maven2 for building.. so what to do :~

Tried using the maven war plugin and change the source dir that didn’t work. So all i done is to create a symbolic link from /src/main: ln -s ../../war/ webapp

that works.. not ideal tho if anyone find another way before I do please leave a comment…

XMPP allows you to create new room on demand. In openfire set the service setting to allow anyone or a list of JID to do this. Then in XIFF create a new Room object with a JID that don’t exist on the server and do a room.join(). There you have yourself a new room with yourself in it :) When doing this openfire use default room configuration however sometimes you would like to have alternate configurations. Such as creating a private room with a password, or a room that is not listed in the directory so you have control on the people in there. This can all be done in XIFF. Although the documentation is a little thin and the API isn’t very easy to work out on how to do it. So this is a mini guide on how can be done as I just manage to discover it myself after go through the source code.

So firstly create your new room in XIFF do something like this:


public function createNewRoom():void{
var room:Room = new Room(_xmppSocketConnection);
//Add the event listener here for the join room event
room.addEventListener(RoomEvent.ROOM_JOIN, config);
room.roomJID = new JID("exDirectoryRoom@service.server.com");
room.join();
}

After joining the room this is where you exec a room.configure method. This method signature takes in fieldmap:Object so is not very intuitive.. emm.. Digging around in the source code this is the room.configure implmentataion:


public function configure(fieldmap:Object):void
{
var iq:IQ = new IQ(roomJID, IQ.SET_TYPE);
var owner:MUCOwnerExtension = new MUCOwnerExtension();
var form:FormExtension;

if (fieldmap is FormExtension) {
form = FormExtension(fieldmap);
} else {
form = new FormExtension();
fieldmap["FORM_TYPE"] = [MUCOwnerExtension.NS];
form.setFields(fieldmap);
}
form.type = FormExtension.SUBMIT_TYPE;
owner.addExtension(form);

iq.addExtension(owner);
myConnection.send(iq);
}

So you can pass in a FormExtension class with all the for var and value as of XMPP spec XEP-0045 or just pass in the var and values directly. If you are doing that the API again isn’t very clear on how this can be done but looking into the source of FormExtension the easiest way is to create a new Dictionary class and the key is the form variable. The value however MUST be an Array. So in my example I want the room to be ex-directory here is what to do:


public function config(event:RoomEvent):void{
var fileds:Dictionary = new Dictionary();
fileds["muc#roomconfig_publicroom"] = new Array(false);
room.configure(fileds);
}

The current beta release of XIFF has a problem in performing a valid disco#items node query as per XEP-0030 spec. When specfying a node using Browser.getNodeItems the node is not pended in the query tag as per spec. The problem is in DiscoExtension.serviceNode. To fix this do change that 1 liner from:

getNode().parentNode.attributes.node = val

to:

getNode().attributes.node = val;

I have posted this on their forum hopfully they can accept it so i dont have to maintain it :D http://www.igniterealtime.org/community/message/190102#190102

I have been using code behind in flex for a while now (weather using framework or not) and using Flex unit + asMock for as tools for unit testing. All works pretty well but I found at some point in my code I have a bunch of method postfixed with Set/GetForTest which makes it all look a lil ugly.. (this is where i miss DI the most :’( )

Although there is a way to do DI in actionscript3 (have a look at swizframework’s code) but there is a more straight forward way to do this. I have named it the ‘Code behind Factory Pattern’). This is essentially a factory that will give you all children components when is needed the setting methods will hide in there so the actual component that is under test will not be littered by set/getForTest code. For example:

I have a componenet (ExtendedPanel) that extends Panel that has 5 children components. Create a class call ExtendedPanelFactory and each getMedthod will take in the current instance ‘this’. The method implmentation will return the actual child component or the mocked one if one is set in its corresponding set method.

We were writing a custom auth prodider for our chat server http://www.igniterealtime.org/projects/openfire/index.jsp. We want the connection from clients to use a special token where using the Default Auth provider from its Admin console. Openfire provide a plugable authentication provider mechanism and provides one call HybridgAuthProvider http://www.igniterealtime.org/builds/openfire/docs/latest/documentation/javadoc/org/jivesoftware/openfire/auth/HybridAuthProvider.html. This auth provider allows us to chain up a list of auth providers which gets executed when the pervious fails. Our custom Auth provider were first in the chain and in its method it thows a Connection Exception rather the the usual UnAutherizeExceptio. Here is the problem if your AuthProvider thorws this it will stop the chaining of the rest of Auth providers which effectivly locking you out if cannot get authenticated in the cuztom one. oO

UIComponent Dictionary

When you make a composite component that extends a existiong one such as Canvas. This component have a varity of VBox’s with HBox’s before you get to the data component. Now you want to access the them your code can get very smelly very quickly, cuz now you have to do a getChildByName(“”).getChaildByName(“).doSomthing. So I reccommed that you make a Dictionary of child component during whil overriding createChildren or initializationComplete with somthing like:

var compDictionary:Dictionary = new Dictionary();
var textInput:TextInput = new TextInput();
compDictionary["childTextInput"] = textInput;

etc…

If you components are in mxml then take the hit of doing alot of getChildBy.. in one of  the life cycle methods so you dont have them all over the place…

One thing for sure when you start writing Flex based flash apps. Sooner or later you get into a point where you want to talk to components next to each other on the screen but yet they are hardly ever related in a parent/daugther way oftern have differents parents. Now for the sake of clean code having dependancies between components breaks encapsulations or ended up with nosey components. I.e. knowing other components and makes things less self contains. Now income actionsscript’s 3 EventDispatcher class. This class can act as your componet’s brother and sister communicator. It has addEventListener and dispatchEvent methods which you can use to talk to componets as long as they listen to the same instace of eventDispatcher. So income the singleton wrapped in a factory.

EventDispatcherFactory{
private static var eventDispatcherObj:EventDispatcher;
public static function getEventDispatcher
if (eventDispatcher == null) eventDispatcherObj = new EventDispatcher()
return eventDispatcherObj;
}

Just back from my 2 weeks holiday and have that the team were really productive. They have finished all the assigned stories few 1 week earlier then expected. So they went and added 2 more stories into the sprint (we run a 2 week sprint starting from Monday ends on a Friday). Come Tuesday I had a chat with a developer and looked at the UAT of the stories they added… ops…. Think they were a little too enthuseastic..

One of the stories had too many UAT for it to be completed in time as they thought they had till Friday until dev work. That is ofcourse not the case.. The QAs needed time to run the UAT feed back any bugs they had fix that and re UAT etc..

Estimate your dev velocity to be couple of day short of your sprint or your QA will be setting up a voodoo doll as they will have to work overtime to have things done :D

Older Posts »