Over a million developers have joined DZone.

OpenXava 4.0: Rapid Java Web Development

DZone's Guide to

OpenXava 4.0: Rapid Java Web Development

· Java Zone
Free Resource

Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code! Brought to you in partnership with ZeroTurnaround.

OpenXava is a framework for rapid development of business applications using Java. It is easy to learn and one can have an application up in no time. At the same time, OpenXava is extensible, customizable and the application code is structured in a very pure object oriented way, allowing you to develop arbitrarily complex applications.

The OpenXava approach for rapid development differs from those that use visual environments (like Visual Basic or Delphi) or scripting (like PHP). Instead, OpenXava uses a model-driven development approach, where the core of your application are Java classes that model your problem. This means you can stay productive while still maintaining a high level of encapsulation.

The all-new version of OpenXava, OpenXava 4.0, improves significantly the user experience, producing a Rich Internet Application user interface. Additionally, some interesting improvements has been done for the developers, such as Groovy, JPA 2.0 or Dependency Injection.

The best way to taste the new features of OpenXava 4.0 is downloading it and following the Quick Start guide.
Below you have some of the main new features present in OpenXava 4.0.

Better User Experience

The next screenshot of a simple OpenXava 4.0 module shows some of the new features:

Another new useful feature of OpenXava is the use of dialogs. OpenXava use them for creating and editing reference and collection elements, though the developer can show his own dialogs in his own actions. Moreover, the user has the possibility of hidding and showing any frame in the view. So he can hide any reference, group or collection to adapt the user interface to his necessities and preferences. The next screenshot shows these features:

These are only some of the user interface new features. OpenXava 4.0 has around 40 improvements of the user interface.

More Options for Developers

OpenXava 4.0 allows to use Groovy for coding all the parts of your application, now it uses JPA 2.0, you can use Dependency Injection in you actions and the way for doing typical tasks has been simplified.
For example, you can use Groovy to define you entity, as following:

year, number, date;
class Order extends Identifiable {

int year

int number

Date date

@ManyToOne(fetch=FetchType.LAZY, optional=false)
Customer customer

@OneToMany(mappedBy="parent", cascade=CascadeType.ALL)
@ListProperties("product.number, product.description, quantity, product.unitPrice, amount")
Collection<OrderDetail> details = new ArrayList<OrderDetail>()

String remarks

BigDecimal getAmount() {
BigDecimal result = 0
details.each { OrderDetail detail ->
result += detail.amount
return result

void calculateNumber() throws Exception {
Query query = XPersistence.getManager()
.createQuery("select max(o.number) from Order o " +
"where o.year = :year")
query.setParameter("year", year)
Integer lastNumber = (Integer) query.getSingleResult()
this.number = lastNumber == null?1:lastNumber + 1


You can use the Java standard for Dependency Injection, JSR-330:x

public class ChangeActiveYearAction extends ViewBaseAction {

@Inject // Standard annotation from JSR-330
private int activeYear; // Getter and setter are not needed

public void execute() throws Exception {
assert activeYear == 2010; // The value from session object
activeYear = 2012; // It changes the value of session object


Thus the activeYear session object is injected in the activeYear field before call to execute(); and after execute() execution the value of the activeYear field is assigned back to the actionYear session object. So, you can change session objects state from inside an action, even with immutable and primitive types.

There are some improvements to the actions that do not add new functionality, but allows you to simplify the coding of some typical cases. For example, now it's easy to add and remove actions programatically from an action thanks to the new methods addActions(), removeActions(), clearActions(), setControllers(), returnToPreviousControllers() and setDefaultControllers()  present in BaseAction. Other new methods of BaseAction such as getRequest(), getContext() and getManager() add a lot of possibilities with little effort.

These are only some of the new features for developers. OpenXava 4.0 has around 90 improvements for the developers.

The Java Zone is brought to you in partnership with ZeroTurnaround. Check out this 8-step guide to see how you can increase your productivity by skipping slow application redeploys and by implementing application profiling, as you code!


Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}