This page contains resources designed to assist you in working with OpenXava.
Installation and Configuration
ABL requires the use of Hibernate, either native or JPA, so you must configure OpenXava accordingly. General instructions are below.
Note: for specific instructions for the BusLogicDemo OpenXava application, click here.
Define your annotated Domain Objects as shown below:
Configure Hibernate/JPA as shown below:
- Identity the Data Source to be used (line 13)
- Register ABL as the event listener(line 19)
- Configure the Data Source location in
Basic App Definition
Application construction is unchanged. Once you define / configure your JPA Beans, you can define the default
application.xml file as shown below. Using this default means you do not need to define html/jsp files, or controllers.
The screen shot below illustrates the code to translates ABL
, as expected by OpenXava, by using the
provided by ABL
You must also alter the
properties/xava.properties file entry to be as shown below:
Naviox - menu and user login
You can obtain naviox to provide application menus, and provide user authentication. In addition to the provided documentation, please note:
- Note that on first execution, Naviox will create several tables such as OXUSERS, OXROLES etc. These will be created in your application's data source.
- Take care to merge Naviox files into your project as shown at right (in particular, it is not a separate project, as in project > properties > build path > Projects Eclipse)
- The concept is that you already have a fully created, running OpenXava project, into which you want to inject Naviox
- The Naviox instructions refer to
UpdateOX - note this is a target inside
build.xml (located in your project root)
- After merging and running UpdateOX, you may need to refresh and clean your project.
- Early per-GA Naviox releases had issues with defining new users; as a temporary workaround, make
source, and dropping the OX** tables in your database to force their recreation on the next run
An example is shown below. It's rather simple and elegant:
- The Module list (on the left) can be opened and closed
- The Horizontal Menu (at the top) is built automatically as users execute desired modules
Refresh after Update
Business Logic makes updates to attributes per derivation rules. In the demo, for example, altering a PurchaseOrder's Paid flag will adjust the Customer's balance. Recall we had to click the Refresh button to see these effects.
So that End Users can see the results of such changes automatically, you may wish to refresh after updates. One way is to define an
application.xml as show below:
Note in particular the indicated lines:
You may find it convenient to develop and test with a version of HQLDB that supports in-memory operation, with options to create the database tables when you open the database. This section describes how you can use this to simplify test data management.
You may find the idea of a database that disappears when it is closed is at first quite odd. But, it can be very useful in testing when combined with a DataLoader that initializes the database every time the application starts up:
- Development - when you run your app, you can be sure of the initial database state. Updates from prior test runs are no longer a concern
- Test Suites - you can ensure that each step in a Test Suite is unaffected by preceding tests
- Logic aware - the DataLoader implementation below loads data through Hibernate/JPA, which thus reflects your business logic. This means that new derivations are reflected when you restart the application. It also means your data is checked for correctness because all the constraints are run!
You can configure OpenXava to load your test data illustrated below, and described in the following sub-sections:
Configure your servers/context.xml like this:
The critical part here is the last line:
mem instructs HSQL to use an in-memory database, and
memdb is just an arbitrary name for that database.
Persistence configured to create tables
As shown in the screen shot above, update your
persistence/META-INF/persistence.xml file to include the following:
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="create" />
First, create your
servlets.xml,and enter its contents as follows:
The parameter (
entityForDataCheck) is optional but can be set to the name of a persistent entity. If it is set, the data loader will check whether the database already has data for this entity, and if it does, it will not load any more data.
You must also execute the deployWar (default) target of your project's
build.xml. This will update
web.xml (which should normally not be edited directly).
Update lib and classpath
- Place them in
- Add commons-beanutils and gson to your class path (Select your project, Properties > Java Build Path > Libraries > Add Jars...)
Provide DataLoaderServlet and DataLoader
You must also provide an implementation of the
. You can obtain implementations used in the BusLogicOX Tutorial here
- Create a package called
- Copy the unzipped files into this package
The sample DataLoaderServlet reads input data from a json file, as shown in the screen shot above.
- Click here to download the sample data (and images)
- Unzip and paste under your projects'
persistence folder (verify the folder structure matches the screen shot illustrated above)