Posts

Showing posts from 2015

Vaadin JPA Container Example

Simple example showing how to use a Vaadin JPA Container The scenario is a Customer entity in a database. You have a use case which requires the retrieval of a customer record by Name and By Number. 1) Set up a Entity Manager private final EntityManager em; 2) Create the Entity Manager from the persistence unit em = JPAContainerFactory.createEntityManagerForPersistenceUnit(< name of persistence unit >); 3) Get Customer By Number - returns a JPA Container which is useful for Vaadin Tables public JPAContainer getCustomerByNumber(String aCustomerNumber) { JPAContainer customer = JPAContainerFactory.make(Customer.class, em); Container.Filter filter = new Compare.Equal("number", aCustomerNumber); customer.addContainerFilter(filter); return customer; } 4) Get Customer By Name - uses JPA named query public Customer getCustomerByName(String aCustomerName) { Query queryCustomerByName = em.createN...

Have Software Components finally arrived

Image
Introduction In April 2013 Dr Dobbs editorial piece summoned a long held vision for software components and reuse. It proclaimed : “After 40 years in the desert of incompatibility and limited reuse, we have crossed the river Jordan.” It was a romantic notion and it provides a sign post for a vision about software components that stretches back to 1968. 1968 Software Engineering NATO Conference Components became part of the software engineering discipline in the very first Software Engineering conference in 1968. Sponsored by NATO, the conference brought together the leading researchers at the time. In a presentation provided by M. D. McIlroy, titled,  “Mass Produced Software Components”, McIlory set out the fundamental principles by which a industry based on the production of software components could be founded. “My thesis is that the software industry is weakly founded, and that one aspect of this weakness is the absence of a software components subindu...

Vaadin - GRID Component

Image
Introduction Vaadin 7.4 was recently released and it includes a new component called the GRID . It represents a 'Spreadsheet" type model from a UI perspective, however I think it lacks a lot of features you would expect from this type of component. Maybe this component will evolve over time and it will begin to have the functions that you expect from a spreadsheet. ( note: there is a commercial add on called the Spreadsheet from Vaadin ) Use Case The use case I am demonstrating below is a simple grid showing projected sales of Widgets over a five year period. Creation Creating a Grid is very simple and you have numerous options for sizing on the page. In the example below I setting it across the page. The Grid rows can be selected for editing, you can select single or multiple rows in a single action. myGrid = new Grid(); myGrid.setSizeFull(); myGrid.setSelectionMode(SelectionMode.SINGLE); Container Backing Similar to many other Vaadin componen...

Google Guava HashBasedTable Example

Image
A simple example showing how to establish a Google Guava Hash Based Table. Notes A class called Board represents a Sudoku Board Create a Hash Based Table which contains a Cell Class Create the Hash Based Table in the constructor Load the board using a int array Print a simple representation of the board Cell class below shows a simple way to represent a cell on a Sudoku Board