Hi Friends,

NetBeans is promoting NetBeans Community Awards here:


Is really great to be included to this team,  these dudes I believe really deserve a recognizement like this.

One of my votes will go to David Strupl :) He looks like one great friend from Brazil Einar Saukas :), besides he did a lot of great things inside NetBeans.

I don't know why Cláudio Miranda, was not in this list, he is one very active community member, and due to his influence a couple of years a go, I am a Netbeans user.

Cláudio, I am sharing this indication with you! Say Hello to your family: Eliane(his wife), Rafael, Murilo and the youngest Renato :)

See you at JavaOne 2006!

Now using Greenbox for Netbeans, you can create a web project with support to Spring, Hibernate and Java Server Faces, with all required libraries to run it.
Check it on the following images:

Image 1 - First step to create a new greenbox project

Image 2 - Final step when you are creating a Greenbox WebProject

Now, I can show you a preview of Greenbox Modules inside NetBeans, We call this module "GAP"(it is not a chothe's trade mark =) ), - Greenbox Annotations Processor .

1 - First Step, you should use Annotations in Greenbox, such as the following image:

2- Second Step  is simple, just pick which element you wanna create and ok, Greenbox will create all elements for you!

In the following links you can see the images above better:

Take a look how easy are Greenbox Annotations! Basically we have only two Annotation's elements:
  • Greenbox
  • GreenboxField
You will get one simple pojo, and will add annotation for java class, and its attributes (fields). Based on this simples pojo (DDD), we will generate all sources (Java, XML, Properties and more).

Take a look on Pojo Pessoa(Person), used for tests:

 1 package br.com.summatech.pessoa;

 3 import<../../span__br.com.versatiliti.annotations.Dao.css;

 8 * Pojo for UseCase Pessoa
 9 * @author edgarsilva
11 @Greenbox(tableName="PESSOA",
12         clientType="web",
13         frameworkCombination="jsf-spring-hibernate")
14 public class Pessoa {
16     @GreenboxField(columnName="CODIGO",
17             label="Codigo da Pessoa",
18             primaryKey="yes",
             hint="Entre com o codigo da Pessoa")
     private Integer codigo;
24     @GreenboxField(columnName="NOME",
25             label="Nome",
26             displaySize="40",
             hint="Entre com o nome da Pessoa",
30     private String nome;
31     @GreenboxField(columnName="EMAIL",
33             displaySize="60",
34             maxSize="200",
35             hint="Entre com o Email da Pessoa",
36             validationExpression="not-null")
     private String email;
     /** Creates a new instance of Pessoa */
42     public Pessoa() {

Doc's Annotations:

Greenbox - Valid only for Classes
  tableName Represents which table this usecase will persist data

Defines if client is Web(JSF) or Desktop (Swing)

N/A (default: Spring+Hibernate+JSF)

GreenboxField - you can use only for Attributes (FIELDS) in the class
   columnName Colum the column in the table
   primaryKey  Defines if is primary key attribute (OR/Mapping) default= "no
   displaySize  Display Size in TextField rendered by JSF ou JTextField

Max size of characters inside Textfield

Tooltip of this Field rendered as JTextField or by JSF

Any idea, or suggestion feel you free to send an email to edgarsilva  (la em) gmail.com


Ok, now It is serious, in the past Greenbox was very particular framework, shared by some friends in Brazil, however we are much more serious, after my session approved in JavaOne, We are investing too much in to make this project such as a real serious and professional Project.

I did a lot of changes in Greenbox, allowing it work with different paths of templates, I added annotations support, and used a lot of sources produced by Fabiano Franz and Lucas Balensiefer.

Righ now greenbox is managed by Alexandre Gomes, and he did a good separation:
  • Greenbox Framework- Core Framework - greenbox<RELEASE>.jar
  • Greenbox Annotations - Core Annotations - greenbox-annotations<RELEASE>.jar
  • NetBeans GB Db IDE - NetBeans plugins running over NetBeans DB Modules to get informations such as Tables, Fields and genereates classes and its attributes.
  • NetBeans Greenbox Annotations Processor - Most professional development over Greenbox, this plugin allow you create very useful applications using Annotations to generate Spring, Hibernate, JSF Applications, and soon JSF+EJB 3.0, basically We will show this development in JavaOne 2006.
For Greenbox Framework, we are using Maven to manage and build the project.

I am writing this points in my blog to organize my ideas, and to share all work I've been doing last days.

We were evaluating JavaForge, due to Subversion project, but we are stabilishing our CVS again in Java.Net.

Hope you enjoy this project, and you can help it too, see https://greenbox.dev.java.net

NetBeans Guys published my interview on NetBeans Home Page, Thanks guys!

If you want to check it out click here tor read this interview

Visit NetBeans Website

I am back and will publish soon new interesting entries.

A Really simple tip for Maven2 users, the following portion inside your pom.xml file, and the mvn site command, can generate the PMD reports automatically for you:



Good Luck!

 I would like to user reporting from stat-cvs in Maven2, But I haven´t found how to do that, or to do this same approach for Subversion, I will continue looking for, If I found it, I will blot it!
This post will show you how to generate sources with greenbox without read informations from database or xmi files.

What you will Need?

  • greenbox2.0-snapshot.jar
  • velocity1.4.x,jar
  • velocity-deps.jar
Creating a basic Class which we will use a Metamodel instance, which we will fill by our own hands to show the work done by greenbox engine while behind the scenes, take a look on that class:

package greenboxsamples;

import ../../page/java.util.ArrayList.css;
import ../../page/net.java.dev.greenbox.base.Attribute.css;
import ../../page/net.java.dev.greenbox.base.Clazz.css;
import ../../page/net.java.dev.greenbox.base.GreenboxContext.css;
import ../../page/net.java.dev.greenbox.core.util.source.generator.base.ClassGeneratorBase.css;

 * Greenbox Usage Samples-Kit
 * @author edgar
public class SimpleVO {
    /** Creates a new instance of SimpleVO */
    public SimpleVO() {
    public static void main(String args[]) {
        //create a new Clazz Instance, which represents a Metamodel
        Clazz classe = new Clazz();
        //Setting Package Name and Class Name
        //creating some fields attributes
        Attribute id = new Attribute();
        Attribute name = new Attribute();
        Attribute email = new Attribute();
        ArrayList attributes = new ArrayList();
        GreenboxContext ctx = new GreenboxContext();
        ctx.declareVariable("today",new java.util.Date().toString());
        try {
        } catch (Exception ex) {

Look that we did all declarations, and with the help from that following template file (pojo.vm) located into template folder in running path:

package  ${classe.packageName}.pojo;
import ../../page/java.io.Serializable.css;
 * Classe de dominío do conceito ${classe.className}
 * @version 1.0
 * @since ${today}
 * @author GreenBox Framework
public class ${classe.className} implements Serializable {
     * Atributos
#foreach( $atributo in $atributos )
    private ${atributo.dataType} ${atributo.name};
     * Construtor em branco do Value Object / Data Transfer Object Pattern de ${classe.className}
    public ${classe.className}() {

We had the following output:

Compiling 1 source file to /home/edgar/summa/projetos/netbeans/greenbox-samples/build/classes
Note: /home/edgar/summa/projetos/netbeans/greenbox-samples/src/greenboxsamples/SimpleVO.java
package  com.summatech.contact.pojo;

import ../../page/java.io.Serializable.css;

 * Classe de dominío do conceito Contact
 * @version 1.0
 * @since Fri Jan 13 04:03:08 GMT 2006
 * @author GreenBox Framework
public class Contact implements Serializable {

     * Atributos
    private int id;
    private String name;
    private String email;

     * Construtor em branco do Value Object
    public Contact() {


BUILD SUCCESSFUL (total time: 2 seconds)


In that tutorial, we checked that the class GreenboxContext is useful to declare which variables will be visible for templates.

The templates are really simples velocity templates.

See you next time

Edgar Silva

Hi Folks...

My friend Claudio Miranda had published a great video teaching how you can create beans and add them to Pallete into NetBeans. Watch this video clicking here

Claudio, congratulations your blog at Java.Net is cool !
I've working at Greenbox 2.0, and I changed my building process from ANT to Maven2.x. In fact Apache ANT is fanstastic, but I can have some cool new features with Maven2.0, and I am so happy with how easy and simple is to work with Maven 2.
After created my Maven Project, using my simple new command line to do that . I was thinking with Me: "Would be goood to work with Maven 2 and NetBeans 5!", but I said to myself : "I think it is a dream, cause it is a real awesome way to work". But after few minutes and with Google helps, I got MavenIDE project, which is pretty good for JBuilder, Eclipse and IDEA, however it  is really incredible for NetBeans.
If you are a NetBeans 5 user, you should read this informations in how to get Maven 2 Support for NetBeans here .
The process to intall is easy, and you can get all related informations and a lot of screenshots and tips here :
To install is really easy, you unzip the files , go to Tools/Update Center, select the "Install Manually Downloaded Modules (nbm. Files) . After select all nbms files unpacked from zip file, and click next until to finish intalling process.
Then you can go to menu File/Open and choose your Maven's project folder, and nothing else... You'll you see the magic! As you can see in the following image:

Click here to see this image better

NetBeans5+Maven2 : A Real productive and happy enviroment to produce real inteligent projects :)


If you wanna use Maven 2.x, this can be a useful tip

Creating a Maven Project Creator Command Line

I've been using Maven 2.x, and I am very happy with their new features, to install is really easy, you can get all informations on Maven Site , and I create a simple but usefeul command line to allow you create project easier.

After to configura your path and this command mvn --version is working fine, you can create your projects. Then if you are using Windows, you can create a file called createproject.bat , ant put the following text:

@ echo off
echo Maven - Create Projects
mvn archetype:create -DgroupId=%1 -DartifactId=%2
echo Project %2 Created sucessfully

Then, you can create in any folder a Maven Project, calling your new command line as the following example:

E:\java\maven2>createproject net.java.dev.greenbox greenbox2

See that %1 is your package, and %2 your project name.

Look the output result:

E:\java\maven2>createproject net.java.dev.greenbox greenbox2
Maven - Create Projects
[INFO] Scanning for projects...
[INFO] Searching repository for plugin with prefix: 'archetype'.
[INFO] org.apache.maven.plugins: checking for updates from central
[INFO] org.codehaus.mojo: checking for updates from central
6K downloaded
[INFO] ----------------------------------------------------------------------------

.... and more

I hope it could be as useful for you as it is for me !  After execute this command, you'll can see a Maven2's project structure, to put you java sources files, in addition a pom.xml file, which will guide you to build really inteligent projects :)

On my NetBeans Plugins development stuff, I've been discovering a lot of nice things, some I must to read netbeans sources, other I can get some tips on NBDEV-LIST, which is useful sometimes,and the last instance I must to say thanks my friends Tim Boudreau and Charlie Hunt, for help me too.

So I would like to share some experiences, I did some nice things using Borland Primetime for JBuilder, and a couple of things using Eclipse, but now, I am trying to improve my development team doing it with generation code and a lot of collaboration and continuous integration. Now, is time to show some simple tricks.

Showing simple messages in NetBeans Platform

    public void showMessage(String str) {
        NotifyDescriptor.Message desc = new NotifyDescriptor.Message(str);
        DialogDisplayer.getDefault().notify( desc );
This will show a simple message, I created a method to do this generic. Apologize me the method name if remind you Delphi but I loved Delphi in the past :)

Using Confirmation Messages

       NotifyDescriptor.Confirmation nd =
                        new NotifyDescriptor.Confirmation( 
                            getBundle( "MSG_ConfirmOpenWitConnection" ),
                            getBundle( "CTL_NotSignedConfirmation" ),
                    nd.setOptions( new Object[] {
                            NotifyDescriptor.NO_OPTION } );
                    Object ret = DialogDisplayer.getDefault().notify( nd );
                    openTables = ret.equals (NotifyDescriptor.YES_OPTION);
The example above, you have to look on ret variable, which holds the boolean result, to do anything you want after this. The first parameter on Confirmation is "The Question message", after, the "Box Title", and ending with the buttons options.

Reading Bundles from TopCompoent Window

    private static String getBundle( String key ) {
        return NbBundle.getMessage

Next time, I will put more tips and tricks to build very useful things in NB plugins development.

see you soon!
Edgar Silva (edgar (em) summa-tech.com )

Are you using Spring Framework, Hibernate and Java Server Faces together?????

And you are tired to manage and to write too much code... Take a look in that Greenbox Thinlet´s Version.

Click here to watch the video

Hi my friends...

Now I will show you how easy is to create a Window Component Plugin in NetBeans 5.0.

My first video received a lot of comments, the main comment was about the quality, I think it is better!

I would like to say thanks to William Lima (Versatiliti Technologies), for host my HTML file wich points to SWF file!

Click here to see!

Thanks for comments! See you
Edgar Silva - edgar (em) summa-tech.com

DAO Pattern Definition

Access to data varies depending on the source of the data. Access to persistent storage, such as to a database, varies greatly depending on the type of storage (relational databases, object-oriented databases, flat files, and so forth) and the vendor implementation.
Reference: Blue Prints


When you are creating your application framework, you would like to persist your data using smart techniques, and I am not talking about Hibernate, JDO, OJB or anything else, however I can ask for you? Can your application support a storage system replacement without any problem? If your asnwer is NO, this text will be useful for you.

Define a Interface as foundation for DAOs

You can define a simple Interface, describing "WHAT" you would like to do, and not "HOW" to do. Getting this idea, we can to think in Interfaces usage. Take a look in the following code:
package br.org.soujava.framework.dao;
import ../../page/java.util.Collection.css;
 *  @author Edgar Silva - [email protected]
public interface IGenericDAO {
	public void save(Object object) throws DAOException;
	public void update(Object object) throws DAOException;
	public void remove(Object object) throws DAOException;
	public Object findByPrimaryKey(Object pk) throws DAOException;
	public Collection findAll() throws DAOException;

You can see that this interface can remind you the EJB EntityBeans model, if you are thinking it is correct! EntityBeans is a great idea, so We can continue using nice ideas(concepts) like that.
In fact, we are exposing that this interface says that It can save, update, remove or find results against Information storage.

We need a simple extension from java.lang.Exception called DAOException, which can be throwed by any method, its source can be as simple as in the following code section:

package br.org.soujava.jobs.framework.dao;
 * @author Edgar Silva - [email protected]
public class DAOException extends Exception {
   public DAOException(String message) {
 public DAOException(Throwable e) {

The Implementation

We talked previouslly about smart codes, so we need to create and use it automaticlly and easier! You can have two choices:
  • Create a DAOFactory class
  • Use Spring Framework


This class will implement a couple of patterns,as such:
Singleton - We will use one and just one instance and
Factory Method - The method returns always an interface, but in execution it will return a concrete class as wich implements this interface, in this case IGenericDAO.
See the following code for DAOFactory:

import ../../page/java.io.IOException.css;
import ../../page/java.util.Properties.css;
 * @author Edgar Silva
 * Esta classe é reponsável em obter todos os DAOS para o Projeto, com base nos nomes

Implementa o Pattern : Singleton e AbstractFactory
* Para uso profissional, seria interessante ter uma HashMap com * os DAOS usados, para prover performance. */ public class DAOFactory { private static DAOFactory me = null; private Properties props = null; private DAOFactory() { try { props = new Properties(); props.load (DAOFactory.class.getResourceAsStream ("daos.properties")); } catch (IOException e) { e.printStackTrace(); } } public static DAOFactory getInstance() { if (null==me) { me = new DAOFactory(); } return me; } /** * Método que retorna o DAO, com base na chave de pesquisa do Arquivo de Properties daos.propeties,
* A Constante passada representa o DAO real que está registraod no arquivo.
* Poderia ser um arquivo XML. * @param name O nome da chave que representa a implementação real do DAO
* ex: getDAO(DAOFactory.DAO_CLIENTES); * Onde DAO_CLIENTES vale "clientes" * E no arquivo de props: * cliente=com.edgarsilva.framework.dao.jdo.ClienteJDOImpl * * */ public IGenericDAO getDAO(String name) { IGenericDAO retorno = null; try { retorno = (IGenericDAO) Class.forName (props.getProperty(name)).newInstance(); } catch (InstantiationException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (ClassNotFoundException e) { e.printStackTrace(); } return retorno; } }

This code is very simple, I usually use it when I am providing Java training classes in Brazil

The DAOFactory is using a properties file to discover the real implementations for DAOs that will be requested by applications. like this following listing:


You can create much better resource of reading, as such to auto-detect changes and update the properties in memory and other stuff.

Using Spring Framework

You can work with Dependency Injection, and you will use the context.xml used in all Spring Applications to describe this dependency.
Other nice Spring's feature is the ability to create DAOs implementations extends the HibernateDAOSupport class, which offer a lot of nice things to make your development easier.

This entry is to make you think that your applications can use dinamic configurations issues, and reduce the coupling between your layers, if you will use Spring or your own IoC framework, the most important is to use some useful DAO strategy as I this text is decribing.