Hi all,

as I announced recently with the email "OFBiz Delegator that uses JPA", I am working now on a drop in replacement that uses JPA as entity model. While the work on the replacement is still in progress, a JAR with the JPA entities has reached a beta state. It can be downloaded from here (about 6MB, source code included):

http://www.mk-multimedia.de/ofbiz/ofbiz-entity-jpa.jar

Because JPA (and J2EE) does not only offer a standard replacement for the database layer but can also improve and accelerate the development of the presentation layer, I like to suggest to consider using (de facto) standard libraries like PrimeFaces (http://www.primefaces.org/showcase/) for improving the UI.

For those of you who are not aware about the power of JPA in an IDE, here is a little tutorial:



Install NetBeans with J2EE-Support
==================================

1. Download NetBeans J2EE Bundle:
        https://netbeans.org/downloads/
2. Install NetBeans and Glassfish:
        https://netbeans.org/community/releases/82/install.html


Setup Glassfish
===============

1. Start NetBeans
2. Klick on the "Services" tab, right click on "Servers" -> add
3. Select "GlassFish Server" and enter a name
4. Set the installation location and choose "Local Domain"
5. Choose a domain location and ports (watch out for conflicts with OFBiz ports!)


Create a database connection, connection pool and JDBC resource
===============================================================

IMPORTANT: My JPA library expects a JDBC resource with the JNDI name "jdbc/ofbiz" (specified in "/META-INF/persistence.xml")!

-> https://netbeans.org/kb/docs/javaee/ecommerce/setup.html


Create a Web-Application
========================

1. File -> New Project
2. Choose the following Project:
        Categories:             Java Web
        Projects:               Web Application
3. Enter the Project Name, e.g. "OFBiz-UI"
4. Choose the Server Settings:
        Server:                 Choose the installed one
        Java EE Version:        Has to be "Java EE 7 Web"
        Context-Path:           The absolute path of the OFBiz-UI URL
5. Select the framework:
        a) Choose JavaServer Faces
        b) Click on "Components" tab and select "PrimeFaces"


Create a UI for an entity
=========================

1. Download the JAR with the JPA entities:
        http://www.mk-multimedia.de/ofbiz/ofbiz-entity-jpa.jar
2. Add the JAR to the libraries of the Web-Application
3. Right click on the Web-Application -> New -> Other:
        Categories:                     Persistence
        File Types:                     JSF Pages from Entity Classes
4. Choose only one entity Class, e.g. "org.apache.ofbiz.party.party.Party", click "Add >" and disable "Include Referenced Classes"
5. Choose packages, folders and templates:
        Session Bean Package:           org.apache.ofbiz.party.ejb
        JSF Classes Package:            org.apache.ofbiz.party.jsf
        JSF Pages Folder:               /
        Localization Bundle Name:       /org/apache/ofbiz/party/PartyBundle
        Choose Template:                PrimeFaces
6. Choose Provider and Database (as specified in "/META-INF/persistence.xml"):
        Persistence Unit Name:          org.apache.ofbiz
        Data Source:                    jdbc/ofbiz
7. Right click on the Web-Application -> Run


Improvements:
=============

- Use Payara instead of Glassfish because it is much more reliable
  -> http://www.payara.fish/downloads

- Use PrimeFaces 6.0 community release
  -> http://www.primefaces.org/downloads

- Use PrimeFaces community theme
  -> http://www.primefaces.org/themes


Greetings

Markus Küspert

Reply via email to