Tag Archives: JSF 2.0

Liferay 6.0.5 + JSF 2.0 + IceFaces 2.0 + Hibernate 3.5.6 – page 2

This tutorial requires that you have read previous page 1 of “Liferay 6.0.5 + JSF 2.0 + IceFaces 2.0 + Hibernate 3.5.6”.

Lets Get Started with the Registration Form Example.
As you have already Installed the LIferay IDE. you can easily create a “Liferay plugin Project“. Put the name “ICEFaces2JSF2Hibernate3”.

You have to create the File structure as below.

Here I will Put the Source code of all the files : Lets start with the xhtml files.
Create a xhtml file called as “application.xhtml” and place it inside WEB-INF/xhtml/

<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ice="http://www.icesoft.com/icefaces/component" xmlns:pcc="http://java.sun.com/jsf/composite/pcc"
	xmlns:ui="http://java.sun.com/jsf/facelets">

	<c:set var="imagesPath" value="#{facesContext.externalContext.requestContextPath}/images" />
	

	<ice:form id="f2" partialSubmit="true" >
		<h3>#{i18n['new-registration']}</h3>
		<pcc:messages globalOnly="true" layout="table" />
		<ice:panelGrid columns="3">

			<ice:outputLabel for="firstName" value="#{i18n['first-name']}" />
			<ice:inputText id="firstName" required="true" value="#{applicantModelBean.firstName}" />
			<h:panelGroup>
				<pcc:message for="firstName" />
			</h:panelGroup>

			<ice:outputLabel for="lastName" value="#{i18n['last-name']}" />
			<ice:inputText id="lastName" required="true" value="#{applicantModelBean.lastName}" />
			<h:panelGroup>
				<pcc:message for="lastName" />
			</h:panelGroup>

			<ice:outputLabel for="emailAddress" value="#{i18n['email-address']}" />
			<ice:inputText id="emailAddress" required="true" validatorMessage="#{i18n['invalid-email-address']}"
				value="#{applicantModelBean.emailAddress}">
				<f:validateRegex pattern=".+[@].+[.].+" />
			</ice:inputText>
			<h:panelGroup>
				<pcc:message for="emailAddress" />
			</h:panelGroup>

			<ice:outputLabel for="phoneNumber" value="#{i18n['phone-number']}" />
			<ice:inputText id="phoneNumber" required="true" value="#{applicantModelBean.phoneNumber}" />
			<h:panelGroup>
				<pcc:message for="phoneNumber" />
			</h:panelGroup>

			<ice:outputLabel for="dateOfBirth" value="#{i18n['birthday']}" />
			<ice:selectInputDate id="dateOfBirth" renderAsPopup="true" required="true" value="#{applicantModelBean.dateOfBirth}">
				<f:convertDateTime pattern="#{portletPreferencesValues['datePattern'][0]}" />
			</ice:selectInputDate>
			<h:panelGroup>
				<pcc:message for="dateOfBirth" />
			</h:panelGroup>

			<ice:outputLabel for="city" value="#{i18n['city']}" />
			<ice:inputText id="city" required="true" value="#{applicantModelBean.city}" />
			
			<ice:commandButton action="#{applicantBackingBean.submit}" partialSubmit="false" value="#{i18n['submit']}" />
		</ice:panelGrid>	
	</ice:form>
</ui:composition>

Hibernate configuration file hibernate.cfg.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
  <session-factory>
    <property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/lportalIceFaces</property>
    <property name="hibernate.connection.username">root</property>
    <property name="hibernate.connection.password">root</property>
    <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
    <property name="hibernate.hbm2ddl.auto">create</property>
    <property name="show_sql">true</property>
    <mapping class="com.navin.iceFacesHibernateLiferay.example.hibernate.Employee" />
    
  </session-factory>
</hibernate-configuration>

Hibernate File Employee.java


package com.navin.iceFacesHibernateLiferay.example.hibernate;
//
/**
 * Employee generated by hbm2java
 */

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "MDOCS")
public class Employee  {

     private long employeeId;
     private String employeeFirstName;
     private String employeeLsatName;
     private String password;
     private String employeeEmail;
     private String phoneNumber;
     private Date dateOfBirth;     
     private String city;
     
    public Employee() {
    }

    public Employee(long employeeId, String employeeFirstName,
			String employeeLsatName, String password, String employeeEmail, String phoneNumber,
			Date dateOfBirth, String city) {
		super();
		this.employeeId = employeeId;
		this.employeeFirstName = employeeFirstName;
		this.employeeLsatName = employeeLsatName;
		this.password= password;
		this.employeeEmail = employeeEmail;
		this.phoneNumber = phoneNumber;
		this.dateOfBirth = dateOfBirth;
		this.city = city;
	}

    @Id
    @GeneratedValue
    @Column(name = "EMPLOYEEID")
	public long getEmployeeId() {
		return employeeId;
	}
    @Column(name = "EFirstName", nullable = false, length=20 )
	public String getEmployeeFirstName() {
		return employeeFirstName;
	}

    @Column(name = "ELastName", nullable = false, length=20 )
	public String getEmployeeLsatName() {
		return employeeLsatName;
	}

    @Column(name = "EPassword", nullable = false, length=50 )
	public String getPassword() {
		return password;
	}

    @Column(name = "EEmailID", nullable = false, length=100 )
	public String getEmployeeEmail() {
		return employeeEmail;
	}
    @Column(name = "EPhoneNo", nullable = false, length=20 )
	public String getPhoneNumber() {
		return phoneNumber;
	}

    @Column(name = "EDateOfBirth", nullable = false, length=15 )
	public Date getDateOfBirth() {
		return dateOfBirth;
	}

    @Column(name = "ECity", nullable = false, length=30 )
	public String getCity() {
		return city;
	}
	public void setEmployeeId(long employeeId) {
		this.employeeId = employeeId;
	}
	public void setEmployeeFirstName(String employeeFirstName) {
		this.employeeFirstName = employeeFirstName;
	}
	public void setEmployeeLsatName(String employeeLsatName) {
		this.employeeLsatName = employeeLsatName;
	}
	public void setPassword(String password) {
		this.password = password;
	}

	public void setEmployeeEmail(String employeeEmail) {
		this.employeeEmail = employeeEmail;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public void setDateOfBirth(Date dateOfBirth) {
		this.dateOfBirth = dateOfBirth;
	}
	public void setCity(String city) {
		this.city = city;
	}

}

Liferay 6.0.5 + JSF 2.0 + IceFaces 2.0 + Hibernate 3.5.6 – page 1

Hi everyone, I am putting together Liferay 6 , JSF 2.0 with IceFaces 2.0 and Hibernate 3.5.6 (Annotations). There are plenty of introductions, tutorials and Documentation, which we will going to explore.

Here we are going to see a very simple example how to integrate all in one. As I believe, everyone will have basic idea of all the above tools. Well I will try to make this blog as simple as possible to understand everyone.

Let first Focus on description of the  above technologies and How to Install it. In the next page we would begin with the basic and simple example.

What is Liferay ?

  • Liferay is a free and Open source Enterprise portal.It is fundamentally constructed of functional units called portlets.
  • Liferay’s support for plugins extends into multiple programming languages, including support for PHP and Ruby portlets.
  • Liferay Portal is Java based and runs on any computing platform capable of running the Java Runtime Environment and an application server. Click here for more Info

What is JSF 2.0 ?

  • JSF’s component architecture defines a common way to build UI widgets.
  • This architecture enables standard JSF UI widgets (buttons, hyperlinks, check-boxes, text fields, and so on), but also sets the stage for third-party components.
  • Components are event oriented, so JSF allows you to process client-generated events (for instance, changing the value of a text box or clicking on a button).

New features in JSF 2.0 :

  • System Events : This feature provides a very fined-grained level of detail to observe and act upon the JSF runtime as it processes requests.
  • Resources : This feature allows the JSF runtime to serve up static resources, such as style sheets, scripts, and images, in addition to the previously available capability to serve up JSF pages.
  • Facelets : Facelets began as an open-source JSF extension that provided first-class templating and easy integration between markup and the JSF API. This made the experience of writing JSF pages easier and more maintainable.
  • Ajax : This feature enables JSF views to communicate with the server directly from the browser without requiring a full-page refresh of the browser window. Ajax is an essential element of most production-quality Web applications currently in production.
  • Composite : Components This feature enables creating true JSF components as aggregations of other JSF components. With this feature, it is easy to build your own custom JSF components and to refactor your existing views into reusable components, complete with listeners, attributes, and events.
  • Partial State Saving : One of the biggest complaints against JSF has been the amount of memory it consumes to maintain view state between requests. This feature dramatically reduces the amount of memory for this purpose, as well as greatly simplifying the API for handling state when developing custom components.
  • And many more……

For more info : jsfcentral.com , Ed Burns has provided a Webinar, slides, data sheet, interview and much JSF 2 coverage in his Bolg . One of the best book JavaServer Faces 2.0:The Complete Reference

What is IceFaces 2.0 ?

    ICEfaces is a JSF framework that allows you to easily create Enterprise-ready Rich Internet applications (RIA) in pure Java. 

  • Open source license, Mozilla Public License.
  • Based on JEE standards and JSF Extensions.
  • Rapidly develop Rich Web Apps in pure Java.
  • Leverages your existing Java ecosystem.
  • Tailored for Enterprise needs, maximizing.
      Developer Productivity
      Scalability
      Portability

more info

What is Hibernate ?

  • Hibernate is an object-relational mapping (ORM) library for the Java language, providing a framework for mapping an object-oriented domain model to a traditional relational database.
  • Hibernate solves object-relational impedance mismatch problems by replacing direct persistence-related database accesses with high-level object handling functions.
  • Hibernate is free software that is distributed under the GNU Lesser General Public License.

more info

Let get started with Liferay and Liferay IDE

Liferay is available bundled with an application server such as Apache Tomcat.

Liferay is available in many versions, download Link.

Download Liferay (bundles with Tomcat) here New Liferay Portal Community Edition 6.0 GA4 has been released

Now, Unzip the files. and Go to the location /$TOMCAT/bin/ “startup.bat”. Double click it to start the Tomcat server.

Now it´s time to install the Liferay IDE plugin for Eclipse. Documentation

More Info

Here you will Find all the Resources . Like the Documentation and PDFs, Wiki , Blogs , Webinars, Slides Shows Click here

Geting started with ICEfaces 2.0

Download the Eclipse plugin from icefaces.org under Tools Support -> Eclipse
here is the documentation where yo can find how you will integrate Eclipse and Icefaces 2.0 . here

ICEfaces uses the portlet bridge which communicate between the JSF and the portlet lifecycle. The portletfaces bridge is already included in ICEfaces 2.0.
ICEfaces developers guide , you will get here icefaces.org

Now Let Start with the simple Example We will develop one Application say Employee Registration. in next page1