Thursday, August 25, 2011

Alfresco Workflow Console

You must login as "admin". http://:/alfresco/faces/jsp/admin/workflow-console.jsp

Tuesday, August 2, 2011

GWT webAppCreator

GWT has a handy utility called webAppCreator. It can be used to create a GWT project with the necessary artifacts, including Eclipse project file and ant build file. It can even create a maven build file - I need to check this out. Details can be found here. The best way to start a GWT project is to run webAppCreator and import it into Eclipse.

Create a clickable GWT ImageCell

Here is my use case. A search returns a list of Document objects. A GWT CellTable displays the list. One of the table columns shows an icon based on document type, i.e., pdf, word etc. When a user double clicks the icon, it retrieves the content of the document.

GWT ImageCell does the icon part nicely. However, there is no built-in behavior to support clicking. To do that, I had to create a subclass of ImageCell and override a couple of methods. The credit goes to a post on stackoverflow.

The code below is the solution. One thing to note is that the Context object provides access to the actual object (Document, in my case) associated with the column. Here I am merely creating an alert with the document name. There are certainly a lot more exciting stuff you can do with it.




Column<Document, String> iconColumn = new Column<Document, String>(
new ClickableIconCell()) {
@Override
public String getValue(Document object) {
return "images/pdf-16.png";
}
};




private class ClickableIconCell extends ImageCell {

@Override
public Set<String> getConsumedEvents() {
Set<String> consumedEvents = new HashSet<String>();
consumedEvents.add("dblclick");
return consumedEvents;
}

@Override
public void onBrowserEvent(Context context, Element parent,
String value, NativeEvent event,
ValueUpdater<String> valueUpdater) {

switch (DOM.eventGetType((Event) event)) {
case Event.ONDBLCLICK:
Document doc = (Document) context.getKey();
Window.alert(doc.name);
break;

default:
break;
}
}
}