Hibernate Search Faceting: Discrete and Range Faceting by Example

In today’s tutorial we’re exploring the world of faceted searches like the one we’re used to see when we’re searching for an item on Amazon.com or other websites. We’re using Hibernate Search here that offers an API to perform discrete as well as range faceted searches on our persisted data. Maven Dependencies Needed For simplicity’s sake am I going to use an HSQL database for persistence, in addition the dependencies for hibernate-entitymanager and hibernate-search (of course) should be added to your pom.xml ...

March 26, 2012 · 5 min · 986 words · Micha Kops

Creating a sample Java EE 6 Blog Application with JPA, EJB, CDI, JSF and Primefaces on GlassFish

Java EE 6 is out and it indeed offers an interesting stack of technologies. So in today’s tutorial we are going to build a small sample web application that builds on this stack using Enterprise JavaBeans, Java Persistence API, Bean Validation, CDI and finally Java Server Faces and PrimeFaces. The application we’re going to develop is a simple blog app that allows us to create new articles, list them and – finally delete them. We’re also covering some additional topics like JSF navigation, i18n, Ajax-enabled components and the deployment on the GlassFish application server. ...

February 8, 2011 · 17 min · 3575 words · Micha Kops

Enterprise Java Bean EJB 3.1 Testing using Maven and embedded Glassfish

Are you playing around with the shiny new 3.1 EJB API? Using Maven for your Java projects? Need an easy way to write and execute tests for your EJBs that depends on an Java Application Server? No problem using Maven Archetypes, the Maven EJB Plugin and the GlassFish embedded Application Container.. Prerequisites For the following tutorial we’re going to need an installation of Maven and of course – the Java Development Kit! ...

January 1, 2011 · 5 min · 969 words · Micha Kops

Bean Validation with JSR-303 and Hibernate Validator

You want to add some validation logic to your Java beans? You want to achieve this with some shiny extendable annotations? Then give the Java Bean Validation standard aka JSR-303 a try.. We’re going to use the reference implementation for bean validation, Hibernate Validator in this tutorial but there are also links to other alternatives like Oval or Apache Bean Validation. So let’s begin and validate some stuff .. Prerequisites JDK >=6 Maven >=2 An IDE or text editor of choice ...

December 14, 2010 · 5 min · 1041 words · Micha Kops

Using PrimeFaces to pimp up existing Java Server Faces / JSF 2 Applications

In this tutorial we’re going to modify an existing Java Server Faces / JSF 2 web application by adding rich UI components to the existing layout. Our tool of choice here is the PrimeFaces framework. It offers a wide range of interesting, customizable and (several) Ajax-enabled components that blend very well with JSF1+2 and also a solid documentation that allows a quick integration into existing projects. Project setup For this tutorial we’re going to reuse the web application from my JSF2 Tutorial “Java Server Faces/JSF 2 Tutorial – Step 1: Project setup, Maven and the first Facelet” – the source code is available at GitHub.org. ...

November 14, 2010 · 6 min · 1197 words · Micha Kops

Object-relational Mapping using Java Persistence API JPA 2

Today we’re going to take a look at the world of object-relational Mapping and how it is done using the Java Persistence API by creating some basic examples, mapping some relations and querying objects using JPQL or the Criteria API.. Prerequisites Java 6 JDK Maven >= 2 If you’d like to take a look behind the scenes e.g. how entities are mapped in your database you could install a RDBMS of your choice .. or just use Derby/JavaDB that is bundled with the JDK 6 ...

October 11, 2010 · 13 min · 2668 words · Micha Kops

Playing around with the Android Animation Framework

Animations add some spice to our Android applications and the offered animation framework makes it easy to create custom animations and tweens. So lets dance around and create some animations ;) .. About There are two ways to create animations – via XML declaration or in a Java class. We’re going to focus on XML declaration – if you’re interested in java based declaration – take a look at the Android JavaDocs and the subclasses of android.view.animation.Animation. ...

September 27, 2010 · 4 min · 820 words · Micha Kops

Creating a SOAP Service using JAX-WS Annotations

It is possible to create SOAP webservices with only a few lines of code using the JAX-WS annotations. In a productivity environment you might prefer using contract-first instead of code-first to create your webservice but for now we’re going to use the fast method and that means code-first and annotations olé! Creating the SOAP Service Create a class SampleService with two public methods Annotate this class with @WebService (javax.jws.WebService) – now all public methods of this class are exported for our SOAP service To change the name of an exported method, annotate the method with @WebMethod(operationName = “theDesiredName”) (javax.jws.WebMethod) Finally the service class could look like this package com.hascode.tutorial.soap; import javax.jws.WebMethod; import javax.jws.WebService; @WebService public class SampleService { @WebMethod(operationName = "getInfo") public String getInformation() { return "hasCode.com"; } public String doubleString(String inString) { return inString + inString; } } ...

September 23, 2010 · 2 min · 400 words · Micha Kops

How to create an Android App using Google’s App Inventor

Today we’re going to take a look at Google’s App Inventor feature that offers programming-novices a nice possibility to enter the fabulous world of Android App programming without deeper knowledge of the API or complex SDK installations. So lets build some stuff .. Prerequisites Java 6 JDK App Inventors Extras Software A Google App Inventor Beta Account – request one here What we are going to build We are building a simple GUI with a Textbox and a button A click on the button starts an event that queries the acceleration sensor for coordinates If the sensor is active and enabled then the coordinates are displayed in the text box ...

August 4, 2010 · 4 min · 749 words · Micha Kops

How to create a simple OSGi Web Application using Maven

In this tutorial we will take a look at the development of a simple OSGi Web Application and what tools can save us some time. The Maven Bundle Plugin makes our life much easier here as does the OSGi Bundle Repository that offers some nice bundles – in our case the servlet API and an embedded Jetty web server. So lets develop some bundles .. Prerequisites You are going to need a JDK (>=5), Maven2, the Apache Felix OSGi implementation and and text editor/http://eclipse.org/[IDE] of your choice. ...

July 25, 2010 · 8 min · 1505 words · Micha Kops