openxava
Blog

September 25, 2019

OpenXava 6.2 released

This new and shiny 6.2 version comes loaded with two new big things: uploading files without page reloading and using drag & drop, and a simplified distribution to improve the developer experience. Additionally, we include a lot of new minor useful features and some fixes.

We invite you to download it and upgrade your OpenXava applications. Look at the migration instructions.

Download OpenXava 6.2

New editors for PHOTO, IMAGE, IMAGES_GALLERY, FILE and FILES stereotypes

These new editors upload the files via AJAX, without page reloading and your user can use drag & drop if he wishes. This is an example of the PHOTO stereotype: 

This one of the IMAGES_GALLERY:

Note as now the gallery is inline, the user don't need to open a dialog to see the images. If the user don't want to see the images he can just collapse the frame.
This is a screenshot for FILE and FILES:

The good news is that you don't need to change your code and you don't need to update your database. Just upgrade your applications to OpenXava 6.2 and your users will be able to manage all their existing images and files in the new way.

Upload your files via AJAX

When you want to load your own file to process it in your way, you can do it using AJAX in a very simple way. The first step is to create a transient class that includes a property of type org.apache.commons.fileupload.FileItem:

package com.yourcompany.uploadtest.model;

import java.time.*;
import org.apache.commons.fileupload.*;

public class ShowFile {
		
	private FileItem file;
	private LocalDate date;

	public FileItem getFile() {
		return file;
	}

	public void setFile(FileItem file) {
		this.file = file;
	}

	public LocalDate getDate() {
		return date;
	}

	public void setDate(LocalDate date) {
		this.date = date;
	}

}
Note as you can have more properties apart from file, such a date property in this case.
Now you have to define a module in application.xml because transient classes are not automatically recognized as modules:
<module name="ShowFile">
	<model name="ShowFile"/>
	<controller name="ShowFile"/>
</module>
Then you have to define the controller with the action to process the file. Add it in controllers.xml:
<controller name="ShowFile">
	<action name="showFile"
		class="com.yourcompany.uploadtest.actions.ShowFileAction"/>    
</controller>
Finally, the logic that process the uploaded file in your action:
package com.yourcompany.uploadtest.actions;

import java.time.*;

import org.apache.commons.fileupload.*;
import org.openxava.actions.*;

public class ShowFileAction extends ViewBaseAction {

	public void execute() throws Exception {
		FileItem file = (FileItem) getView().getValue("file");
		LocalDate date = (LocalDate) getView().getValue("date");
		addMessage(file.getName() + " shown on: " + date);
		addMessage(file.getName() + " content: " + file.getString());
	}

}
In this case we just display the content as string in a message, but you can do whatever you want with the file using the FileItem API. Note as using the other properties of the view, date in this case, is done in the usual way.

The above code is just an example. The idea is that you define a property of type FileItem and you can use it as a regular property in your code, without worring about JSPs, servlets, etc. It just work as a regular property. The old way for uploding files still works, and all your old code will work as always, without AJAX. 

Simplified distribution

Programmer Experience. Possibly this concept doesn't even exist. We work hard in order our users would have a smooth experience with our product, but what about us? Currently configuring the development enviroment to work with a new technology is question of days, even for expert developers. In OpenXava we always have worked againts this tradition, and in v6.2 we have turn it up a notch, with these simplifications:

  • Projects can be launched directly using Run As > Application in Eclipse.
  • No longer is needed to have a Tomcat installed for development.
  • Eclipse for Java Developers is enough, no longer Eclipse for Java Enterprise Developers needed.
  • Each new project includes a DBManager to launch a HSQLDB manager.
  • Getting started guide simplified.
  • Quick start guide removed.
  • Guide for deploying on Tomcat.
  • Doc for configuring MySQL, PostgreSQL, Oracle, Microsoft SQL Server, AS/400, Informix, Db2 and Firebird.
  • MySchool demo project no longer included in distribution.
  • OpenXavaTemplate and OpenXavaPlantilla projects removed from distribution.
  • CreateNewProject.xml and CrearNuevoProyecto.xml available in OpenXava project directly.

The effect is that you can create a new project and run it, in seconds. You don't need to configure a Tomcat, or create a database, or configure a datasource, or anything. Just after creating a project you can run it in this way:

This means that newcomers are going to have less problems in order to start with OpenXava, however for advanced users is also useful, using Eclipse for Java Developer and starting/stopping the application without Tomcat is faster.

Other improvements

We have done a lot of improvements in other areas:

  • Images of PHOTO stereotype are shown in tiny size in list mode.
  • Import data in list mode uses AJAX for uploading the CSV/Excel file.
  • New uploadFile(), removeFile(), assertFile(), assertNoFile() and assertFilesCount() in ModuleTestBase.
  • New WithFileItem class to use as transient class for dialogs or views to just upload a file.
  • InvoiceDemo includes examples of PHOTO and GALLERY_IMAGES stereotypes.
  • Workspace in distribution upgraded to Eclipse 2019-09, though it still works with Neon (4.6).
  • Rows per page in list can be up to 50.
  • Length limit in stereotype MEMO/TEXT_AREA to avoid extremely large pages.
  • Grouping by in list mode has a year and month entry for each LocalDate property.
  • Filtering by year, month and year/month in list mode for LocalDate columns.
  • Lessons from 1 to 3 of the course use LocalDate instead of Date.
  • @ReadOnly(onCreate=false) in order the member would be editable on create and read only in the other cases.
  • DBServer class to start a HSQLDB and its manager.
  • Methods of SaveAction, CreateNewElementInCollectionAction and SaveElementInCollection made protected.
  • The methods setHidden() and setEditable() of View accept qualified member names. 
  • Specifying application on creating a new test is no longer needed.
  • Some new common use labels to be used in applications.
  • DWR warning messages no longer shown in log.
  • Commons Codec API available to be used in applications.
  • Servlet API 4.0 included, though we still are compatible with Servlet 3.0.
  • New smtpFromEmail property in xava.property to define a 'from' email different than smtpUserId. 
  • New methods isIE() and isFF() in Browsers utility class.

Bug fixes

Though this is not a maintenance version we have done some fixes:

  • Fix: Isolate state for several browser tabs in the same module fails in nginx.
  • Fix: Some broken links in menu of the Spanish View chapter of reference guide.
  • Fix: assertDiscussionCommentsCount() from ModuleTestBase does not work when CSS is disabled.
  • Fix: Editors with format=false and no formatter fail if the type has no an editor associated.
  • Fix: Unused servlets defined in web.xml.
  • Fix: Broken image when PHOTO stereotype with no image is shown in list.      
Download OpenXava 6.2

blog comments powered by Disqus

Español - 中文