Posts

Showing posts from July, 2013

Java EE 7 enterprise application development tutorial using Eclipse Kepler and GlassFish 4

Image
In this tutorial, I am going to use the latest technologies (to date) Eclipser Kepler GlassFish 4 as an Enterprise application server MySQL 5.6 JSF 2.2 Maven NOTE: The second blog of this is available in the JSF 2 Ajax . I am going to use archetypes to create EAR, EJB and WAR components. First, add the maven repository archetype catalogue http://repo1.maven.org/maven2/archetype-catalog.xml to the eclipse archetype selecting the Windows->Preferences and then Maven. Fig: 1 add maven archetype catalogue. The next step is crating a web project. As shown in the following fig 2, you can find webapp-javaee7. If you have little knowledge about maven, you can create new web application. Fig 2: select archetype to create WAR, EAR and EJB For example as shown in the following fig 3, you need to specify the Group Id, Artifact Id and Package. For both WAR and EJB project you will get the following error but it can be ignored. “Plugin execution not covered by lifecycle configur...

JSF 2.0 Ajax

Image
This is the second compilation of the tutorial Java EE 7 enterprise application development tutorial using Eclipse Kepler and GlassFish 4 . In this tutorial, I’ve enhanced the application to purely use the JSF 2 Ajax. As shown in the following diagram, I used Firebug to trace the Ajax request and response. As you see, jsf.js is the magic of JSF 2 Ajax. As shown in the above figure, when you add a new department, without refreshing the entire page, it updates the table under the “submit” button. Here the source for the facelet <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> < html xmlns = " http://www.w3.org/1999/xhtml " xmlns: ui = " http://java.sun.com/jsf/facelets " xmlns: h = " http://java.sun.com/jsf/html " xmlns: f = " http://java.sun.com/jsf/core " > < h: head > < title...

JAX-RS access via JSON using jQuery

Image
This is the continuation of the blog JSF 2.0 Ajax . In the blog JSF 2.0 Ajax , I’ve considered the Ajax access using JSF 2.0. In JSF, you always have to use the Managed bean. As I see managed bean is over-managed therefor more code needs to be added to avoid the undesirable side effects such as save twice. The REST approach is simple but not secure. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> < html xmlns = " http://www.w3.org/1999/xhtml " xmlns: ui = " http://java.sun.com/jsf/facelets " xmlns: h = " http://java.sun.com/jsf/html " xmlns: f = " http://java.sun.com/jsf/core " > < h: head > < script src = " http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js " > </ script > </ h: head > < body > < form action = "...

JPA Part 3: Basic Relationships

Image
If you think in independent of source and target sides, one of the two sides will have the join column. That side is called the owning side or the owner of the relationship. The side that does not have the join column is called the non-owning or inverse side. If they are not there, the values default from the perspective of the attribute on the owning side. Physical annotations that define the mapping to the columns in the database are always defined on the owning side of the relationship. @ManyToOne mappings are always on the owning side of a relationship, so if there is a @JoinColumn, it should be found on the Many sides. @OneToMany is practically always bidirectional. Therefore, mappedBy must be specified, that is the inverse. Another side is @ManyToOne that is the owning side. @OneToOne, logically either side can be an owning sides. But you cannot avoid the ownership. Therefore, @mappedBy element is added to the inverse side (which is you decided) to indicate that the othe...