GWT architecture best-practices

Its an excellent video that lists down many interesting things: A must watch for UI archs.

Just to summarize few of the architecture points discussed in this (and my comments)
1. MVP pattern usage in GWT. (using gwt-presenter library probably)
2. Dependency injection on client side (Google-gin (client-side) and Google-Guice(server side))
3. Event Bus (following event collaboration by martin fowler
4. Command Pattern (probably using gwt-dispatch)

Hope it helps.. Please share your understandings as well.

Storing images in the database.

[tweetmeme source=”snarayan” only_single=false]

My personal opinion is that going forward, more and more images would be stored in the database instead of the file server. (for enterprise kind of applications).
Though currently, most databases are not equipped to handle images efficiently.

Current Concerns with the approach:
1. Slow retrieval : It is generally considered slower to retrieve images from db. Though it is fast changing.
2. Size of db : Size of db becomes large. creating backup issues.
3. Complex : It is more complex to add/retrieve images from db.
4. Caching : It is relatively more complex to cache/index images in the db. URL/image caching is easier.

1. Backup : It just simplifies the backup process. Also it reduces the risk of not syncing up the database with the file-system resulting in the “image not found” errors.
2. Secure : It adds more fine-grained control on the security of access-control, since all rules of db apply on them.

Under current circumstances, it is better to NOT have images images in the database (unless you’re willing to invest in oracle 10g, which handles images better than most servers)

Some other alternatives could be Amazon S3, variety of CMS, Document repositories, etc.

Grails-Jasper plugin starter issues..

Jasper is one of the better solutions on the reporting side from the open-source perspective.  Also, Grails has been growing in popularity as the chosen framework to write web-apps which were ought to be written in Java.

In this post, I’ll stick to the grails-jasper plugin. It expects you to know basics of grails and jasper.

Off we go then..

On the editor side, I prefer Eclipse and eclipse-plugin JasperAssistant than iReport. There are many advantages with that. It is much more simple & lightweight.
Regarding the issue with Grails, I went ahead with installing the plugin and was able to generate reports.

One great help was:
after installing the plugin, go to the url

It gives few sample implementations of the jasper plugin. Once they’re working, you’re set to use the reports.

Some issues I faced were:

Issue : report/MyReport.jasper or .jrxml not found.

Solution: Need to create a report folder in web-app and copy all the .jasper & .jrxml files there.

Reason : The plugin expects the files to be there. It can be modified by changing the configuration.groovy file.

Issue : PDF(output) is empty

Solution: Data is not bound to the report file.

My solution was I created my own Controller to access data and pass it to jasper (instead of the default jasper query)

class ReportController {


def testExample = {
// This “data” object in this data model is the data that drives this Jasper report (i.e. what appears in the
// detail band)

List reportDetails = Race.list();


// here jasper is the plugin provided controller.
// and index is the default method in jasper controller.
// we need to pass the data and the params.


list.gsp (front end) has the following tag

<g:jasperReport controller=”report”              >> calls the report controller
jasper=”all-races”            >> the jasper file
action=”testExample”        >> the action(method) in the controller
format=”pdf”            >> format can be pdf, excel, etc.
name=”ReportFile”            >> Name of the file exported

all-races.jrxml (report file) has the following lines

// fields provided to the report. They’ll be equivalent to the Object provided in collection.
// e.g. List<Person>, Person class would be available and each field is its attribute.

<field name=”name”/>
<field name=”city”/>

// usage of the field:

<textFieldExpression   class=”java.lang.String”><![CDATA[$F{name}]]></textFieldExpression>
<textFieldExpression   class=”java.lang.String”><![CDATA[$F{city}]]></textFieldExpression>

I hope it helps.