Archive

Archive for the ‘WEB 2.0’ Category

GWT Quickstart Project with Maven+GWT2.3+GIN1.5

July 14th, 2011

Hi,

Been a while… This post will show you, and remind me in the future, how to quickly setup a

GWT 2.3 project with Maven2 and GIN 1.5. I’m using Ubuntu, but the essential steps should be the same in any operating system.

Let’s start.

Assuming you have maven installed, just run:

mvn archetype:generate -DarchetypeRepository=repo1.maven.org -DarchetypeGroupId=org.codehaus.mojo -DarchetypeArtifactId=gwt-maven-plugin -DarchetypeVersion=2.3.0-1

Then, enter the details for you new GWT 2.3 project. Don’t forget that the property for ‘module’ should be a valid Java Class name, so use camel case when setting the name of module.
My configurations are something like:

Define value for property 'groupId': : eu.jpereira.gwt
Define value for property 'artifactId': : quickstart
Define value for property 'version': 1.0-SNAPSHOT:
Define value for property 'package': eu.jpereira.gwt:
Define value for property 'module': : Quickstart
Confirm properties configuration:
groupId: eu.jpereira.gwt
artifactId: quickstart
version: 1.0-SNAPSHOT
package: eu.jpereira.gwt
module: Quickstart

Now, we just need to add the dependency to GIN 1.5. Open the generated POM for the Quickstart project and add the dependency for GIN 1.5:

<!-- GIN Stuff -->
<dependency>
	<groupId>com.google.gwt.inject</groupId>
	<artifactId>gin</artifactId>
	<version>1.5.0</version>
	<scope>provided</scope>
</dependency>

Now you have a GWT 2.3 project with GIN 1.5 and Maven.
To finalize, let just remind how to setup GIN with the GWT project.
Generate the eclipse project:

mvn eclipse:eclipse gwt:eclipse

Open the project in eclipse and edit the *.gwt.xml (in my case, this is the file Quickstart.gwt.xml) file, located under “src/main/resources/” to import the GIN module:

<inherits name="com.google.gwt.inject.Inject" />

Create the GinModule, the class file that will configure the dependency injection for your application. You can have any number of GinModules. Check the documentation here: http://code.google.com/p/google-gin/wiki/GinTutorial
I like to keep everything related to GIn under the package *.client.gin. My Module is this:

package eu.jpereira.gwt.client.gin;

import com.google.gwt.inject.client.AbstractGinModule;
import com.google.inject.Singleton;
import eu.jpereira.gwt.client.QuaickstartApplication;

public class QuickstartGinModule extends AbstractGinModule {

	@Override
	protected void configure() {
		bind(QuaickstartApplication.class).in(Singleton.class);

	}
}

Here I’m only binding the QuickstartApplication object, which is my main application, like this:

package eu.jpereira.gwt.client;

import com.google.gwt.user.client.Window;

public class QuaickstartApplication {

	public void run() {
		Window.alert("Hello World!!!");
	}
}

Back to Gin setup, let’s create the Ginjector. Create a new Interface that extends from Ginjector:

package eu.jpereira.gwt.client.gin;

import com.google.gwt.inject.client.GinModules;
import com.google.gwt.inject.client.Ginjector;
import eu.jpereira.gwt.client.QuickstartApplication;
@GinModules(QuickstartGinModule.class)
public interface QuickstartInjector extends Ginjector{
	QuickstartApplication getQuickstartApplication();
}

Finally, it’s time to use it. In the Quickstart.java, which contains the entry point to the application, remove everything, create the injector and start your application.

package eu.jpereira.gwt.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;

import eu.jpereira.gwt.client.gin.QuickstartInjector;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Quickstart implements EntryPoint {

	/**
	 * This is the entry point method.
	 */
	public void onModuleLoad() {
		QuickstartInjector injector = GWT.create(QuickstartInjector.class);
		injector.getQuickstartApplication().run();

	}

}

Now, run the application with:

mvn gwt:run

And you should see the “Hello World!!” alert.

BTW, you can download the project here.

Happy coding!!!!

GWT, java, programming, Software, WEB 2.0

The problem with Java Web development frameworks is…

February 8th, 2011

Well, from my point of view, the problem of Java Web development frameworks is that there are too many. Each one has its strengths and weaknesses, like anything else. I’m excluding those that are proprietary and you have to pay to use them. Really, why would people pay for such kind of thing?

Focusing on what is open source, you just need to see those supported by Apache: http://projects.apache.org/indexes/category.html#web-framework

Then you can see a list of Java web development frameworks (result of a Google search):
http://java-source.net/open-source/web-frameworks

There’s are so many and the community does not focus on building a complete Java Web Development Framework. The one I like more is Play! Framework because it’s a complete stack of java technologies that really help the development of web apps and it borrows many concepts from Ruby on Rails, which it’s my favorite.

I don’t know every Java web development framework, of course, and each must have their strengths and serve different purposes, but my feeling is that if there were only a few, then the community will focuses on improving those and we’ll end with a truly good framework.

java, programming, Software, WEB 2.0

Yeahh, I’m building it with enterprise ready technologies… who cares?

February 5th, 2011

If you have an web product idea and want to test it, i.e. put it in front of your users, what it’s the most critical aspect to consider first? I usually get my head into a conflict, because I’m used to work with the so-called “enterprise ready technologies”, namely JEE. My mind if formatted to think about all aspects that a good enterprise product should have. I start giving more attention to a set of quality attributes like performance, usability, reusability, testability, portability, modifiability, etc, etc, and give less attention to one critical aspect, if I want to get a product in front of the users fast: productivity.

So, I start looking to what is out there that is enterprise ready, like EJBs, JSF, Hibernate, JBoss, Tomcat, whatever, and start getting the pieces together…. out there in the world there was some a guy with the same product idea, but considered first the productivity aspect of the equation and started to materialize the idea with, let’s say, Ruby on Rails…. guess who’s the winner?

I’m not against the use of JEE, of course, I just think that in some cases it does not make sense. I also have this false argument in my mind: What if I start building it with PHP and then hit a performance problem with my 1Million users? Well, If I ever had one million users, I’ll be happy to deal with these performance issues :)

Agile, java, programming, Ruby, Software, WEB 2.0

Where’s my Java reflection?, Part II

January 30th, 2011

Just to give the final implementation started in “Where’s my Java reflection“, here it goes the implementation of the generator for the method bindErrors (check last post “Where’s my Java reflection“ to get into context):

private void composeBindErrorsMethod(TreeLogger logger,
			SourceWriter sourceWriter, TypeOracle typeOracle) {

		sourceWriter.println("public void bindErrors("
				+ parameterizedType.getQualifiedSourceName()
				+ " object, Map<String, List<String>> errors) {");

		// Get the fields declared in the parameterized type
		JField[] fields = parameterizedType.getFields();
		for (JField field : fields) {

			JClassType classType = field.getType().isClass();
			if (classType != null) {

				JClassType erroableType = typeOracle.findType(Errorable.class
						.getName());

				if (classType.isAssignableTo(erroableType)) {

					sourceWriter.println("if (errors.containsKey(\""
							+ field.getName() + "\")){");
					sourceWriter.println("object." + field.getName()
							+ ".setErrors(errors.get(\"" + field.getName()
							+ "\"));");
					sourceWriter.println("}");

				}
			}

		}
		sourceWriter.println("}");

Again, hope it helps anyone.

GWT, java, programming, WEB 2.0

Where’s my Java reflection?

January 30th, 2011

Some people like it, others don’t. I like it, it’s so cool to make generic code, but as I ‘ve been experimenting with GTW to know it’s capabilities I found that GWT does not support Reflection. It uses instead a mechanism called Deffered Binding to overcome the lack of reflection.

When doing some kind of framework code with GWT, soon you’ll realize that you need reflection, as I did. Bad luck, you’ll have to dig into the underground features of GWT, namely deferred bindings and generators. You can learn the theoretical traits of Deferred Bindings in the documentation: http://code.google.com/webtoolkit/doc/latest/DevGuideCodingBasicsDeferred.html

Let me explain my scenario.

Read more…

GWT, java, Javascript, Software, WEB 2.0

Set focus on first input of a form

October 16th, 2010

Isn’t annoying when you open a web page with a form and then have to click on the first input to start entering our data?

Well, it’s so easy to make this automatically with Javascript and JQuery

$("input:visible:enabled:first").focus();

Javascript, Software, WEB 2.0

Tenham cuidado com o que partilham nas redes Sociais

March 25th, 2010

Há uns dias atrás vi os meus streams do Facebook, Twitter e Buzz cheios de mensagens acerca de subscrições que fiz a alguns canais do Youtube. Acredito que para quem viu esse fluxo de mensagens foi um grande desprazer. Também foi para mim porque quando integrei estas contas (Youtube, Buzz, Twitter e Facebook) não pensei muito no assunto e devia-me ter precavido destas situações.

floodPior ainda, é que algumas das mensagens estavam duplicadas (Português e Inglês), como podem ver ali na imagem à esquerda.

Mas há quem faça pior. Há quem insista em partilhar tudo nas redes sociais. Por vezes parece que estou a ver a caixa de entrada do email de algumas pessoas, se me enviarem o número do cartão de crédito agradecia :)

No Google Buzz, que estou a ponderar desactivar, recebi a seguinte mensagem do stream de alguém:

Alguém quer lhe conhecer no Badoo!

Outra pessoa por perto quer lhe conhecer. Vá até o Badoo e veja se a atração é mútua. Decida quem você quer conhecer!

http://ping.fm/—–

Obrigado,
A Equipe Badoo

Esta é uma mensagem de envio somente. Respostas a esta mensagem não são monitoradas ou respondidas.
Você recebeu esta mensagem como um usuário registrado no ,
para controlar que emails você recebe, por favor, modifique as suas configurações:

http://ping.fm/—-

WTF? Então só para passar o tempo, segui o primeiro link e qual é a minha surpresa que estava agora na posse de uma conta desse serviço (Badoo), com acesso à conta por completo… pena não se algo que me interessasse mais :)

Já não é a primeira vez que isto me acontece. Da última vez foi alguém, com o mesmo nome que eu e provavelmente com um endereço de email muito parecido, que se enganou a introduzir o email no Hi5 e lá fiquei com acesso completo à conta do rapaz…

Se quiserem dar acesso às vossas contas de serviços de redes sociais e outros, utilizem um serviço que publique a vossa caixa de correio no stream do Buzz e outros streams.

Ficam avisados :)

Blogging, WEB 2.0

A TMN ainda não percebeu o Twitter

December 23rd, 2009

Um cliente liga para o 1696 da TMN e diz:

Cliente: queria saber qual é o melhor plano para acesso à internet através do telemóvel sem carregamentos obrigatórios.

TMN: Zzzzz!! Zzzzz!!

Cliente: estão-me a ouvir?

TMN: Zzzzzz!! Zzzzz!!

Isto não aconteceu com o 1696 mas aconteceu com o Twitter. A TMN tem uma conta do twitter @tmn_pt, mas não responde a estas questões através do Twitter…. Não sei se eles querem propositadamente ignorar este canal de comunicação ou então não perceberam ainda que o Twitter também serve para eles se relacionarem com os clientes e não apenas para fazer publicidade.

twitter_tmn

http://twitter.com/joaomrpereira/statuses/6836740450

O que acham? Acham que a TMN poderia usar o Twitter sem ser apenas para fazer publicidade mas também para responder a questões dos clientes?

WEB 2.0 , ,

Para os amantes do Ruby on Rails e não só

December 13th, 2009

Este post é para os amantes de Ruby on Rails e não só. É também para os amantes do desenvolvimento de Software.

Para quem não conhece Ruby on Rails (RoR), RoR é uma framework para desenvolvimento ágil de aplicações Web. Utiliza a linguagem de programação Ruby. Uma framework equivalente, mas em Java, pode ser o  Tapestry 5, por exemplo, que também é uma framework para desenvolvimento ágil de aplicações Web, mas em linguagem Java.

RoR não é a única framework para desenvolvimento de aplicações Web com Ruby e uma das mais activas frameworks “rivais” ao RoR é a Merb.

A novidade aqui, pelo menos para mim, é o anúncio do merge entre Ruby on Rails e Merb no RoR 3.

Fica aqui um vídeo com a  novidade, dada pelo criador do RoR, que não é um anúncio, mas uma aula.

Para quem não liga nada a RoR, pode ver a partir do minuto 45, tem umas excelentes dicas para qualquer pessoa envolvida no desenvolvimento de software. :)

Quero aproveitar também para emendar um pequeno detalhe num dos meus últimos posts. No post ‘O poder do “E” e do ‘Mas’” quero alterar de Programador para Parceiro :) . Vejam o vídeo a partir do minuto 58 para perceber porque é que quero mudar isso :) . Ahh! E vejam também a resposta à primeira pergunta, a partir do minuto 59

Vale a pena ver mesmo quem não quiser saber nada de RoR, mas quiser saber alguma coisa sobre desenvolvimento de Software.

Read more…

Software, WEB 2.0 , , ,

Convites Google Wave

November 25th, 2009

Já tenho uma conta no Google Wave à algum tempo e ainda não ofereci os meus convites todos. Hoje a Google deu-me mais alguns convites e fiquei com 23. Quero dá-los porque ficar com eles não me serve de nada. No entanto, gostaria de dar os convites a quem realmente quiser  usar o Google Wave.

Ainda se notam alguns “bugs” no software, por isso é que ainda é fechado, mas já dá para fazer umas coisas muito interessantes.

Um vídeo em Português sobre o Google Wave.

Na minha opinião é uma ferramenta única para colaboração. Se alguem quiser um convite deixe-me um comentário com uma pequeno texto a descrever para que querem utilizar o Wave.

Boas ondas.

Software, WEB 2.0 , , ,