Posts

How to convert a string to a SQL date

Image
  Steps SimpleDateFormat  - create a class that encapsulates the format of the date you are creating.  Parse the date sent using the method to ensure it meets date formatting requirements. Throw a parse exception if the date is invalid. Create a sqlDate from the parsed date. Use the number of milliseconds from  January 1, 1970, 00:00:00 GMT as an input into the method. This ensures the accuracy of the formed SQL date. Return the sqlDate to the method caller. 

The CSV Editor - The Beginning

Image
What am I doing..?  What began as a process to learn JavaFX  has turned into a lengthy, mistake-driven, process. I have learnt a lot and gained an appreciation for creating something which has value and at the same time provides a pathway for learning. CSV Editor - the starting point It seemed a simple idea. Build a CSV Editor in JavaFX.  I started by looking for an example and soon found this remarkable free tool CSVed . This editor did everything and much more. There isn't a feature that isn't covered by this tool and its long revision history ( dating back to 2008 !!! ) is a testament to software endurance. I decided I wouldn't be as bold.  I would play it safe, set the features small, and climb the software ladder one step at a time. I had years of Java experience but my JavaFX experience was minimal.  The Features So, using my loved Modelling tool, Sparx Enterprise Architect from Sparx Systems , I mapped out my main features. And so began a journey of rabbit holes, b

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 subindustry

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

Jersey Rest Basics

Image
I use the Jersey Rest API  and I always deploy to Tomcat. There are some basic things you need to do to make this work. There are few examples around the internet which are very good, but they seem to be focused on some very old versions of the framework. Number 1, make sure your web xml contains this configuration. Number 2, I use Maven , so this is my Pom File, this example includes the dependency for using JSON processing. Number 3, write some code. That's for another blog entry.