Filed under NetBeans

Use JPA with Hibernate in Netbeans(Tomcat)

0. prerequisite
  Tomcat 6.0.14
  Netbeans 6 rc1
  Hibernate core 3.2.5GA
  Hibernate EntityManager 3.3.1GA

1. Add a new JPA library implement
  The default used TopLink. Change to Hibernate.
Untitled

2. Adjust in JSF design
The default data provider ObjectArrayDataProvider works not well with JSF design UI.

image

  My target is when let a jsf table “Bind to Data”, the all fields of a Hibernate JOPO can be chosen as the  above dialog. These displayed fields come from provider’s getFieldKeys method which is part of interface DataProvider signature. So the simplest way is to extends ObjectArrayDataProvider and overide that method. Or just use setObjectType(Student.class). Be sure to compile that class manually so the JSF Design can take this change into account.

Why not use :

private ObjectArrayDataProvider objectArrayDataProvider1 = new ObjectArrayDataProvider(someType);

It does not work. Even I put them in _init() method of backend bean, as the CachedRowSet provider does.

3. Done.

Visual library of NetBeans

Today I evaluated Visual library of NetBeans org. There are not too much information about it on Sun’s site. And it is a part of NetBeans 6 M9. I guest it was just separated from Netbeans as a standalone project. It’s many feature is same as JGraph which has been used by many users. But I think this library provides more about UI design but not only concerning on graph as done by JGrah. For example, it has a feature “ComponentWidget – AWT/Swing components on scene”. So you can do this:

JButton button = new JButton();
button.setText("xixi");
ComponentWidget widget = new ComponentWidget(this,button);

Then I have a question: Is Visual Web (netbeans) developed on this library? If so, Visual Library is very cool! (From this post, just page flow navigator is based on Visual Library.)
There is a video which created a demo on Visual library. You can find that a JasperReports tool called jarvis is also base on this library. It looks powerful.