Skip to main content

Posts

Facebook4j definitely!

I think that the best library to connect to and interact with Facebook from a Java web application is Facebook4j ( http://facebook4j.org/en/index.html ). I am not a big fan of Facebook, but I needed to interact with the most popular social network and had to search for a solution to this requirement. Facebook4j is an high level Java library for the Facebook Graph API. It doesn't require additional dependencies, it's Open Source and released under the Apache License 2.0 and it has built-in OAuth support. The learning curve is very low and you need just few lines of code to perform any kind of interaction with Facebook. Before moving to Facebook4j I tried also other APIs (among them RestFB and the now deprecated java-facebook-api) and Spring Social. At the end Facebook4j was the best, the most well documented and the easiest to use. I had to discard Spring Social because the application I am working on is not Spring based. This application is hosted on Google App Engine and I eas...

Localization in GWT UiBinder howto

In GWT the localization process is more complex using the UiBinder declarative layout than the Java layout and the official documentation is lacking. In this post I will shortly describe the steps to follow to localize your UiBinder views. First of all you have to add the local properties to your GWT XML module file: <inherits name="com.google.gwt.i18n.I18N"/> <extend-property name="locale" values="en"/> <extend-property name="locale" values="it"/> In this example I am considering English and Italian as possible languages. Then you have to add the locale namespaces to any of the *.ui.xml file of your project: <ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui"  ui:generateFormat="com.google.gwt.i18n.rebind.format.PropertiesFormat"        ui:generateKeys="com.google.gwt.i18n.rebind.keygen.MD5KeyGenerator"  ...

New article about Axon framework

It's on line now the March issue of Mokabyte magazine ( www.mokabyte.it ). It contains a new article ( http://www2.mokabyte.it/cms/article.run?articleId=8NU-7JY-S5U-KM4_7f000001_26089272_3efb3042 ) wrote by me about the Axon framework ( http://www.axonframework.org/ ), a Java implementation of the CQRS (Command Query Responsibility Segregation) pattern. This article is the third of four. The column on the right shows you the links to read my other articles about Axon and CQRS. The article is in Italian language only, but please feel free to ask me any kind of info in English about it. I'd like to know also your impressions about CQRS or Axon if you already had applied them to any of your projects.

Model View Presenter pattern

Model View Presenter (MVP) is a software design pattern that brings a lot of benefits developing web applications having GWT as frontend framework. I am going to do a brief description of this pattern. I am currently applying it on a project I am working on and I have noticed that for people coming from MVC (Model View Controller) sometimes it's hard to understand the benefits of MVP (and how to implement it): so I decided to share my experience explaining this pattern from scratch. MVP is a derivative of the MVC pattern and it's used mainly for building user interfaces. As well as the MVC pattern, MVP decouples the model from the views and the views from the logic that controls them. This way you really have the separation of concerns for the presentation logic. The three actors of this pattern are: Model: an interface defining the data to be displayed. View: a passive interface that displays the data of a model and routes user commands (typically events) to the presente...

jOOQ: code generation in Eclipse

jOOQ allows code generation from a database schema through ANT tasks, Maven and shell command tools. But if you're working with Eclipse it's easier to create a new Run Configuration to perform this operation. First of all you have to write the usual XML configuration file for the code generation starting from the database: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-2.0.4.xsd">   <jdbc>     <driver>oracle.jdbc.driver.OracleDriver</driver>     <url>jdbc:oracle:thin:@dbhost:1700:DBSID</url>     <user>DB_FTRS</user>     <password>password</password>   </jdbc>   <generator>     <name>org.jooq.util.DefaultGenerator</name>     <database>       <name>org.jooq.util.oracle.OracleDatabase</name>     ...

SuggestBox in GWT UiBuinder

I am currently working also on a project hosted on Google App Engine ( http://appspot.com ) and I want to share some tips about some of the frameworks offered by the GAE environment. Today I want to talk about a problem we had using the GWT SuggestBox component while making UiBinder layouts. The class  com.google.gwt.user.client.ui.SuggestBox is  a text box or text area which displays a pre-configured set of selections that match the user's input.  Each SuggestBox  is associated with a single  com.google.gwt.user.client.ui.SuggestOracle . The SuggestOracle  is used to provide a set of selections given a specific query string. Our application provides a method to retrieve suggestions from the backend while a user writes into the SuggestBox. This worked fine with a GWT Java layout, but moving to UiBinder layout we faced the following problem. We added a SuggestBox to a view through the GWT designer. The code generated was the following: View.ui.xml: ...

Apache Camel rocks!

Yesterday I attended a meeting of the JBoss User Group @ Red Hat in Rome. One of the two topics of this meeting was an introduction to Apache Camel ( http://camel.apache.org/ ). Last summer Red Hat acquired Fuse Source and now they are promoting Apache Camel. It is a powerful Open Source integration framework based on the most used Enterprise Integration Patterns (EIPs,  http://www.eaipatterns.com/toc.html ).  Camel allows you to define routing and mediation rules in a lot of domain-specific languages, including Java, Spring, XML and Scala DSL. It provides more than 120 components and so it's possible to work directly with any kind of  transport or messaging model. The following image taken from the official website shows the Camel architecture: Camel brings a lot of benefits. How many times it would have been useful in some past projects! But it's never too late to start with it.