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;
	}

}
Advertisements

Tagged: , , , ,

12 thoughts on “Liferay 6.0.5 + JSF 2.0 + IceFaces 2.0 + Hibernate 3.5.6 – page 2

  1. Cesar Quinteiro October 18, 2011 at 10:03 am Reply

    HI

    I am trying same target, but with Hibernate 3.6 instead, first I try a sample from liferay web, with a “JSP-Portlet Hibernate” and works, then I made a “Icefaces Hibernate Project (tomcat 7)” and also works and finally I made a “Liferay/Icefaces Porlet/Hibernate” and works fine for reading data but not for saving, the code I use (in all cases) that I debug and know that is fire, is the following:
    *********Code************
    session.beginTransaction();
    foodItem = (FoodItem)session.merge(foodItem);–> refresh data reading from DB
    session.update(foodItem); —> Here nothing happens
    session.getTransaction().commit();
    **************************

    do have Idea why is not saving?
    do you have any place where I can download your sample to tested?

    regards

    • navinagarwalmca October 31, 2011 at 9:02 pm Reply

      Hi Cesar , Sorry for late replay ..
      well in your code for saving .. you need to use
      session.save(Object);
      then its going to add a new entry into Database. well you can check the code Here

      I hope it will help you a lot . 🙂

  2. air Jordan Shoes November 17, 2011 at 4:47 pm Reply

    Youre so cool! I dont suppose Ive read anything like this before. So nice to search out somebody with some authentic thoughts on this subject. realy thanks for beginning this up. this web site is one thing that is wanted on the web, somebody with a little bit originality. useful job for bringing one thing new to the web!

  3. Przewozy Autokarowe November 22, 2011 at 2:42 am Reply

    Oh my goodness! an amazing article dude. Thank you Nonetheless I’m experiencing concern with ur rss . Don’t know why Unable to subscribe to it. Is there anybody getting identical rss downside? Anybody who knows kindly respond. Thnkx

  4. Angry birds online November 25, 2011 at 5:03 pm Reply

    Great – I should certainly pronounce, impressed with your web site. I had no trouble navigating through all tabs as well as related info ended up being truly simple to do to access. I recently found what I hoped for before you know it in the least. Reasonably unusual. Is likely to appreciate it for those who add forums or something, website theme . a tones way for your customer to communicate. Excellent task.

  5. Jordan France November 28, 2011 at 2:51 pm Reply

    Its like you read my mind! You seem to know a lot about this, like you wrote the book in it or something. I think that you can do with a few pics to drive the message home a little bit, but instead of that, this is excellent blog. A great read. I’ll certainly be back.

  6. wedding dresses November 29, 2011 at 12:12 am Reply

    Very fantastic info can be found on weblog.

  7. Diego January 16, 2012 at 1:35 pm Reply

    Hi, your article is very ussefull. Could you explain how create the project?. I imported your war and works fine. Thank´s.

    • navinagarwalmca January 17, 2012 at 4:50 pm Reply

      Thanks Diego!! I am going to write a new Blog with the whole Explanation.

  8. repetitive stress injury June 20, 2013 at 11:59 am Reply

    Howdy, I think your site could possibly be having internet browser compatibility
    issues. When I take a look at your web site in Safari,
    it looks fine but when opening in IE, it’s got some overlapping issues. I just wanted to give you a quick heads up! Aside from that, excellent site!

    • navinagarwalmca June 23, 2013 at 1:57 pm Reply

      thanks for info and comment , I have checked in IE, but no issue i faced, IE behave very differently sometimes.

  9. Priscilla August 7, 2013 at 7:15 pm Reply

    My family members all the time say that I am killing my
    time here at web, but I know I am getting knowledge all the time by reading such good content.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: