init.jsp
<%@taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui" %>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<%@taglib uri="http://liferay.com/tld/theme" prefix="theme" %>
<%@taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<%@page import="java.util.List"%>
<%@page import="com.liferay.portal.kernel.util.ListUtil"%>
<%@page import="com.liferay.arav.service.aravLocalServiceUtil"%>
<%@page import="com.liferay.arav.model.arav"%>
<%@page import="com.liferay.arav.model.impl.aravImpl"%>
<theme:defineObjects></theme:defineObjects>
add.jsp
<%@ include file="/html/arav/init.jsp" %>
<portlet:actionURL var="addActionURL" name="employeeDetails">
<portlet:param name="action" value="employee"/>
</portlet:actionURL>
<aui:form action="<%= addActionURL %>" method="post" name="sub">
<aui:input name="name" type="text"></aui:input>
<aui:select multiple="false" name="designation">
<aui:option value="developer">Developer</aui:option>
<aui:option value="tester">Tester</aui:option>
<aui:option value="manager">Manager</aui:option>
</aui:select></br>
<b>dateofbirth</b></br>
<liferay-ui:input-date formName="dob" yearRangeEnd="2000" yearRangeStart="1950"
yearValue="1990" monthValue="3" dayValue="20" dayParam="d1" monthParam="m1"
yearParam="y1">
</liferay-ui:input-date></br></br>
<aui:button type="submit" value="Add Employee"></aui:button>
<a href="<portlet:renderURL/>">« Go Back</a>
</aui:form>view.jsp
<%@ include file="/html/arav/init.jsp" %>
<portlet:renderURL var="employeeURL">
<portlet:param name="jspPage" value="/html/arav/add.jsp"></portlet:param>
</portlet:renderURL>
<portlet:renderURL var="listEmployeeURL" >
<portlet:param name="jspPage" value="/html/arav/list.jsp"></portlet:param>
</portlet:renderURL>
<aui:a href="<%= employeeURL %>"><b>ADD EMPLOYEE DETAILS</b></aui:a>
<aui:a href="<%= listEmployeeURL %>"><b>EMPLOYEE DETAILS</b></aui:a>
list.jsp
<%@ include file="/html/arav/init.jsp" %>
<%
List<arav> list = aravLocalServiceUtil.getaravs(-1, -1); %>
<liferay-ui:search-container delta="10" emptyResultsMessage="No
Employee details available">
<liferay-ui:search-container-results results="<%=
ListUtil.subList(list, searchContainer.getStart(),searchContainer.getEnd()) %>"
total="<%= list.size() %>" />
<liferay-ui:search-container-row
className="com.liferay.arav.model.arav"
modelVar="aravinth">
<liferay-ui:search-container-column-text property=
"name" />
<liferay-ui:search-container-column-text property="designation" />
<liferay-ui:search-container-column-text property="dob" />
<liferay-ui:search-container-column-text property="age" />
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
<a href="<portlet:renderURL/>">« Go Back</a>ACTION.JAVA
package com.liferay.arav;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import com.liferay.arav.model.arav;
import com.liferay.arav.model.impl.aravImpl;
import com.liferay.arav.service.aravLocalServiceUtil;
import com.liferay.counter.service.CounterLocalServiceUtil;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.theme.ThemeDisplay;
import com.liferay.util.bridges.mvc.MVCPortlet;
/**
* Portlet implementation class aravAction
*/
public class aravAction extends MVCPortlet {
public void employeeDetails (ActionRequest actionRequest,
ActionResponse actionResponse) throws IOException {
String name = ParamUtil.getString(actionRequest, "name");
String designation = ParamUtil.getString(actionRequest, "designation");
System.out.println(name);
System.out.println(designation);
String date=ParamUtil.getString(actionRequest,"d1");
System.out.println(date);
Integer month=ParamUtil.getInteger(actionRequest,"m1")+1;
System.out.println(month);
String year=ParamUtil.getString(actionRequest,"y1");
System.out.println(year);
String mo=month.toString();
String a=date+"/"+mo+"/"+year;
Date ar=new Date(a);
System.out.println(a);
ThemeDisplay themedisplay = (ThemeDisplay)
actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
arav arav = new aravImpl();
long aravId = 0l;
arav.setName(name);
arav.setDesignation(designation);
arav.setDob(ar);
Calendar cal=Calendar.getInstance();
int currentyear=cal.get(Calendar.YEAR);
int birthyear=ParamUtil.getInteger(actionRequest,"y1");
long age=currentyear-birthyear;
System.out.println(age);
arav.setAge(age);
try {aravId = CounterLocalServiceUtil.increment (arav.class.getName());
arav.setAravId(aravId);
aravLocalServiceUtil.addarav(arav);
} catch (SystemException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
service.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.1.0//EN"
"http://www.liferay.com/dtd/liferay-service-builder_6_1_0.dtd">
<service-builder package-path="com.liferay.arav">
<author>esquare2</author>
<namespace>arav</namespace>
<entity name="arav" local-service="true" remote-service="false">
<!-- PK fields -->
<column name="aravId" type="long" primary="true" />
<!-- Audit fields -->
<column name="companyId" type="long" />
<column name="userId" type="long" />
<column name="userName" type="String" />
<column name="createDate" type="Date" />
<column name="modifiedDate" type="Date" />
<!-- Other fields -->
<column name="name" type="String" />
<column name="designation" type="String" />
<column name="dob" type="Date" />
<column name="age" type="long" />
<!-- Order -->
<order by="desc">
<order-column name="dob" />
</order>
<!-- Finder methods >
<finder name="Field2" return-type="Collection">
<finder-column name="field2" />
</finder> -->
</entity>
</service-builder>
<%@taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui" %>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<%@taglib uri="http://liferay.com/tld/theme" prefix="theme" %>
<%@taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<%@page import="java.util.List"%>
<%@page import="com.liferay.portal.kernel.util.ListUtil"%>
<%@page import="com.liferay.arav.service.aravLocalServiceUtil"%>
<%@page import="com.liferay.arav.model.arav"%>
<%@page import="com.liferay.arav.model.impl.aravImpl"%>
<theme:defineObjects></theme:defineObjects>
add.jsp
<%@ include file="/html/arav/init.jsp" %>
<portlet:actionURL var="addActionURL" name="employeeDetails">
<portlet:param name="action" value="employee"/>
</portlet:actionURL>
<aui:form action="<%= addActionURL %>" method="post" name="sub">
<aui:input name="name" type="text"></aui:input>
<aui:select multiple="false" name="designation">
<aui:option value="developer">Developer</aui:option>
<aui:option value="tester">Tester</aui:option>
<aui:option value="manager">Manager</aui:option>
</aui:select></br>
<b>dateofbirth</b></br>
<liferay-ui:input-date formName="dob" yearRangeEnd="2000" yearRangeStart="1950"
yearValue="1990" monthValue="3" dayValue="20" dayParam="d1" monthParam="m1"
yearParam="y1">
</liferay-ui:input-date></br></br>
<aui:button type="submit" value="Add Employee"></aui:button>
<a href="<portlet:renderURL/>">« Go Back</a>
</aui:form>view.jsp
<%@ include file="/html/arav/init.jsp" %>
<portlet:renderURL var="employeeURL">
<portlet:param name="jspPage" value="/html/arav/add.jsp"></portlet:param>
</portlet:renderURL>
<portlet:renderURL var="listEmployeeURL" >
<portlet:param name="jspPage" value="/html/arav/list.jsp"></portlet:param>
</portlet:renderURL>
<aui:a href="<%= employeeURL %>"><b>ADD EMPLOYEE DETAILS</b></aui:a>
<aui:a href="<%= listEmployeeURL %>"><b>EMPLOYEE DETAILS</b></aui:a>
list.jsp
<%@ include file="/html/arav/init.jsp" %>
<%
List<arav> list = aravLocalServiceUtil.getaravs(-1, -1); %>
<liferay-ui:search-container delta="10" emptyResultsMessage="No
Employee details available">
<liferay-ui:search-container-results results="<%=
ListUtil.subList(list, searchContainer.getStart(),searchContainer.getEnd()) %>"
total="<%= list.size() %>" />
<liferay-ui:search-container-row
className="com.liferay.arav.model.arav"
modelVar="aravinth">
<liferay-ui:search-container-column-text property=
"name" />
<liferay-ui:search-container-column-text property="designation" />
<liferay-ui:search-container-column-text property="dob" />
<liferay-ui:search-container-column-text property="age" />
</liferay-ui:search-container-row>
<liferay-ui:search-iterator />
</liferay-ui:search-container>
<a href="<portlet:renderURL/>">« Go Back</a>ACTION.JAVA
package com.liferay.arav;
import java.io.IOException;
import java.util.Calendar;
import java.util.Date;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import com.liferay.arav.model.arav;
import com.liferay.arav.model.impl.aravImpl;
import com.liferay.arav.service.aravLocalServiceUtil;
import com.liferay.counter.service.CounterLocalServiceUtil;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.theme.ThemeDisplay;
import com.liferay.util.bridges.mvc.MVCPortlet;
/**
* Portlet implementation class aravAction
*/
public class aravAction extends MVCPortlet {
public void employeeDetails (ActionRequest actionRequest,
ActionResponse actionResponse) throws IOException {
String name = ParamUtil.getString(actionRequest, "name");
String designation = ParamUtil.getString(actionRequest, "designation");
System.out.println(name);
System.out.println(designation);
String date=ParamUtil.getString(actionRequest,"d1");
System.out.println(date);
Integer month=ParamUtil.getInteger(actionRequest,"m1")+1;
System.out.println(month);
String year=ParamUtil.getString(actionRequest,"y1");
System.out.println(year);
String mo=month.toString();
String a=date+"/"+mo+"/"+year;
Date ar=new Date(a);
System.out.println(a);
ThemeDisplay themedisplay = (ThemeDisplay)
actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
arav arav = new aravImpl();
long aravId = 0l;
arav.setName(name);
arav.setDesignation(designation);
arav.setDob(ar);
Calendar cal=Calendar.getInstance();
int currentyear=cal.get(Calendar.YEAR);
int birthyear=ParamUtil.getInteger(actionRequest,"y1");
long age=currentyear-birthyear;
System.out.println(age);
arav.setAge(age);
try {aravId = CounterLocalServiceUtil.increment (arav.class.getName());
arav.setAravId(aravId);
aravLocalServiceUtil.addarav(arav);
} catch (SystemException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
service.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.1.0//EN"
"http://www.liferay.com/dtd/liferay-service-builder_6_1_0.dtd">
<service-builder package-path="com.liferay.arav">
<author>esquare2</author>
<namespace>arav</namespace>
<entity name="arav" local-service="true" remote-service="false">
<!-- PK fields -->
<column name="aravId" type="long" primary="true" />
<!-- Audit fields -->
<column name="companyId" type="long" />
<column name="userId" type="long" />
<column name="userName" type="String" />
<column name="createDate" type="Date" />
<column name="modifiedDate" type="Date" />
<!-- Other fields -->
<column name="name" type="String" />
<column name="designation" type="String" />
<column name="dob" type="Date" />
<column name="age" type="long" />
<!-- Order -->
<order by="desc">
<order-column name="dob" />
</order>
<!-- Finder methods >
<finder name="Field2" return-type="Collection">
<finder-column name="field2" />
</finder> -->
</entity>
</service-builder>