Laliwala IT Services

Laliwala IT Services
Website Development

Monday, March 28, 2011

Simple Struts Portlet, tutorial, portlet, struts tutorial, liferay strusts portlet

Code Snippets for various examples.

Prepared by Aasif and Ahmed under the guidance of Irshad Mansuri

Attune Infocom
----------------------------------------------------------------------------------
===============================================================2. Simple Struts Portlet

2.1. portlet-ext.xml
--------------------
<portlet>
<portlet-name>library</portlet-name>
<display-name>library Portlet</display-name>
<portlet-class>com.liferay.portlet.StrutsPortlet</portlet-class>
<init-param>
<name>view-action</name>
<value>/ext/library/view</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
<resource-bundle>com.liferay.portlet.StrutsResourceBundle</resource-bundle>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
</portlet>

2.2. liferay-portlet-ext.xml
----------------------------
<portlet>
<portlet-name>library</portlet-name>
<struts-path>ext/library</struts-path>
<use-default-template>false</use-default-template>
</portlet>

2.3. liferay-display.xml
------------------------

add

<portlet id="library" />

inside

<category name="category.example">

2.4. struts-config.xml
----------------------
<action path="/ext/library/view" forward="portlet.ext.library.view" />

2.5. tiles-defs.xml
-------------------
<definition name="portlet.ext.library" extends="portlet" />
<definition name="portlet.ext.library.view" extends="portlet.ext.library">
<put name="portlet_content" value="/portlet/ext/library/view.jsp" />
</definition>


(create the following two jsp files under "/ext/ext-web/docroot/html/portlet/ext/library")

2.6. init.jsp
-------------
<%@ include file="/html/portlet/init.jsp" %>
<p>Add commonly used variables and declarations here!</p>

2.7. view.jsp
-------------
<%@ include file="/html/portlet/ext/library/init.jsp" %>
Simple Struts Portlet!

2.8 Language-ext.properties
---------------------------

Add a new entry in the above file,
javax.portlet.title.library=library Portlet

2.9 Deploy and verify
---------------------

run "ant deploy" from ext to move all the changes we have done so far both under "ext-web" and "ext-impl"

Restart the server and check the new library portlet is working perfectly fine.

This portlet will be the basis for all other concepts we are going to learn in the subsequent chapters.

All the best !!







Check that Library Portlet is available under Training Categroty.





Check out that Library Portlet is added successfully.









Simple Struts Portlet, tutorial, portlet, struts tutorial, liferay strusts portlet

Friday, March 25, 2011

liferay tutorial, simple jsp portlet, basic jsp, portlet

Code Snippets for various examples.

Prepared by Aasif and Ahmed under the guidance of Irshad Mansuri

Attune Infocom pvt. ltd.
----------------------------------------------------------------------------------

===============================================================
1.Basic JSP Portlet
===============================================================

[the xml files are located under "ext/ext-web/docroot/WEB-INF"]

1.1. portlet-ext.xml
--------------------

(insert the below content)

<portlet>
<portlet-name>EXT_2</portlet-name>
<display-name>JSP Portlet Introduction</display-name>
<portlet-class>com.liferay.util.bridges.jsp.JSPPortlet</portlet-class>
<init-param>
<name>view-jsp</name>
<value>/html/portlet/ext/jsp_portlet/view.jsp</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
<resource-bundle>com.liferay.portlet.StrutsResourceBundle</resource-bundle>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
</portlet>

1.2. liferay-portlet-ext.xml
----------------------------

(insert the below content)

<portlet>
<portlet-name>EXT_2</portlet-name>
</portlet>


1.3. liferay-display.xml
------------------------

(insert the below content)

<category name="category.example">
<portlet id="EXT_2" />
</category>

1.4. view.jsp
-------------

(create this file under "ext/ext-web/docroot/html/portlet/ext/jsp_portlet"
and enter the below contents)

Welcome to simple Basic JSP Portlet

Note: after this step do "ant deploy" from "ext-web"

1.5 Language-ext.properties
---------------------------

(under /ext/ext-impl/src/content)

Add two new entries in the above file,

javax.portlet.title.EXT_2=JSP Portlet

category.example=Training

Note: after this step do "ant deploy" from "ext-impl"

1.6 Restart the server and check
--------------------------------

Restart the server and check you get the new portlet under the "Training" category








Goto to Add application




See new category Training is made under which there is newly created JSP portlet.






JSP Portlet is successfully added.



Liferay tutorial JSP Portlet

Liferay tutorial JSP Portlet
Liferay portlet development training
Liferay training attune infocom
Liferay JSP portlet development


Code Snippets for various examples.

Prepared by : Irshad Mansuri

Attune Infocom
----------------------------------------------------------------------------------

===============================================================
1.Basic JSP Portlet
===============================================================

[the xml files are located under "ext/ext-web/docroot/WEB-INF"]

1.1. portlet-ext.xml
--------------------

(insert the below content)

<portlet>
<portlet-name>EXT_2</portlet-name>
<display-name>JSP Portlet Introduction</display-name>
<portlet-class>com.liferay.util.bridges.jsp.JSPPortlet</portlet-class>
<init-param>
<name>view-jsp</name>
<value>/html/portlet/ext/jsp_portlet/view.jsp</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>
</supports>
<resource-bundle>com.liferay.portlet.StrutsResourceBundle</resource-bundle>
<security-role-ref>
<role-name>power-user</role-name>
</security-role-ref>
<security-role-ref>
<role-name>user</role-name>
</security-role-ref>
</portlet>

1.2. liferay-portlet-ext.xml
----------------------------

(insert the below content)

<portlet>
<portlet-name>EXT_2</portlet-name>
</portlet>


1.3. liferay-display.xml
------------------------

(insert the below content)

<category name="category.example">
<portlet id="EXT_2" />
</category>

1.4. view.jsp
-------------

(create this file under "ext/ext-web/docroot/html/portlet/ext/jsp_portlet"
and enter the below contents)

Welcome to simple Basic JSP Portlet

Note: after this step do "ant deploy" from "ext-web"

1.5 Language-ext.properties
---------------------------

(under /ext/ext-impl/src/content)

Add two new entries in the above file,

javax.portlet.title.EXT_2=JSP Portlet

category.example=Training

Note: after this step do "ant deploy" from "ext-impl"

1.6 Restart the server and check
--------------------------------

Restart the server and check you get the new portlet under the "Training" category

Wednesday, March 16, 2011

tomcat liferay

liferay language navigation portlet

liferay language navigation portlet

problems faced in liferay 6

1.) In Blogs portlet, on clicking “Publish” button in while editing comments, Bolgs portlet shows error – “Blogs is temporarily unavailable”.

Monday, February 28, 2011

database connection in liferay 5.2.3, liferay tutorial, liferay mysql, liferay jdk, liferay tomcat, liferay database

How to Make Database connection in Liferay-5.2.3

In this example we are going to see the database connectivity with MySQL and a simple example of it. Here the Prerequisite for doing connection with database.

• Install the JDK and set the Path JAVA_HOME variable .
• Set the Path for Ant ANT_HOME variable .
• Install MySQL (remember the port number, username and pasward).
• Make a Folder For your Workspace where the Liferay folders you are going to keep like EXT and Tomcat etc.
• You must know the how to make simple struts Portlet with action file.

Make sure that above things have been done accordingly and check your Liferay is working properly.Now follow the following steps to do a connection with database.

Step 1 : Set the following code in portal-ext.properties under path(~\liferay-portal-ext-5.2.3\ext-impl\src\ portal-ext.properties) in your Liferay folder.
This step you may have done at time of liferay setup if you have then check it out.

Code :
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost:3309/test?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=root
jdbc.default.password=root

Make sure that the port number you have given is correct in default url and the username, password, and database/schema name is correct.

Step 2 : Now ant deploy from ext-impl and from ext, make sure that it’s done successfully now restart the tomcat and check in MySQL database name as you given in this example we used the name test.

Step 3 : Make the table with your need for this example we are taking the table for testing called book the following statement is for creating the table.

create table Book (
bookId bigint(10) not null primary key,
title VARCHAR(75) null,
dateAdded datetime
);

Write the above statement in MySQL screen than perform the transaction, refresh the Database and check the table.

Step 4 : Make service.xml on this /ext/ext-impl/src/com/ext/portlet/library path here the Library is the folder of your portlet where this file you have to place. Write the following is the service.xml





Library











Step 5 : Now do the following steps to build the service for above table.

• Go to "/ext/ext-impl"
• Execute "ant build-service -Dservice.file=src/com/ext/portlet/library/service.xml"
• Make sure the build is successful
• Confirm all the service layer files are generated as per the Spring/Hibernate framework. check under
o ext/ext-impl/src/com/ext/portlet/library
o ext/ext-service/src/com/ext/portlet/library

Step 6 : Updating service layer class – 1

file location : ext\ext-
impl\src\com\ext\portlet\library\service\impl\BookLocalServiceImpl.java

now write the functionality for database insert. insert this method.

import com.ext.portlet.library.model.Book;
import com.ext.portlet.library.model.impl.BookImpl;

import java.rmi.RemoteException;
import com.liferay.portal.PortalException;
import com.liferay.portal.SystemException;
import com.liferay.counter.service.CounterServiceUtil;
public Book create(String title)
throws PortalException, SystemException, RemoteException {

// create a primary key
long bookId = CounterServiceUtil.increment(Book.class.getName());

// instantiate an empty object
Book book = new BookImpl();
book.setBookId(bookId);
book.setTitle(title);

// persist the book object
book = bookPersistence.update(book, false);

// return the object to caller
return book;
}
Step 7 : Run ant build-service again to re-generate the corresponding Util interfaces. Do the following steps.

• execute "ant build-service -Dservice.file=src/com/ext/portlet/library/service.xml"
• execute "ant compile" to compile all the generated file and make sure the build is SUCCESSFUL.

Step 8 : Now Update the action file which is made at location "ext/ext-impl/src/com/ext/portlet/library/action". The following is the code to written in Action file name as AddBookAction.java

package com.ext.portlet.library.action;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletConfig;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.liferay.portal.struts.PortletAction;
import com.liferay.portal.kernel.util.Validator;
import com.ext.portlet.library.service.BookLocalServiceUtil;

public class AddBookAction extends PortletAction {

public void processAction(
ActionMapping mapping, ActionForm form, PortletConfig config,
ActionRequest req, ActionResponse res)
throws Exception {

String bookTitle = req.getParameter("book_title");

if (Validator.isNull(bookTitle)) {
setForward(req, "portlet.ext.library.failure");
} else {
// new line to be inserted
BookLocalServiceUtil.create(bookTitle);
setForward(req, "portlet.ext.library.success");
}
}

public ActionForward render(ActionMapping mapping, ActionForm form,
PortletConfig config, RenderRequest req, RenderResponse res)
throws Exception {
if (getForward(req) != null && !getForward(req).equals("")) {
return mapping.findForward(getForward(req));
} else {
return mapping.findForward("portlet.ext.library.view");
}
}
}

Step 9 : Now do run "ant deploy" from "ext" for this do the following steps.

• go back to /ext folder and execute "ant deploy"

• make sure the build is SUCCESSFUL.

• check the newly generated jar files "ext-impl.jar" and "ext-service.jar"

Step 10 : Start tomcat and check the portlet. try to add some books and make sure the values are getting saved in the database.

Note : the structs portlet steps was not shown in this section so do that steps by ur self before doing this steps.


_________________________________________________________________________________
Laliwala IT Services
Mangal Girdhar Compund, Nr. B.G.Tower, Dehli Darwaja, 
 Ahmedabad - 380004
Gujarat, India
Email : imran@laliwalait.com
Telephone: +91-9904245322

spring framework, spring application, spring training

spring framework is an open source application framework.
spring help to j2ee developer.
j2ee application famous in 1999.
spring is applicable in a wide range of environments not just server side j2ee app. the original motivation for spring was the j2ee environment, and spring offers many valuable services, for use in j2ee applications.
spring is lightweight frameworks

oriented programming framework
data access abstraction
jdbc simplification
transaction management
mvc web framework
simplification for working with jndi, jta, j2eeapis
lightweight rmoting

Saturday, February 26, 2011

jbpm tutorial, elipse tutorial, jbpm training, liferay jbpm training, liferay tutorial

JBPM Double Approver in liferay portal download

Steps for creating double approver

1.Download jbpm-jpdl-designer-site-3.1.7 from here Download

2.open Eclipse goto->help->Install New Software and in archive select the zip file downloaded

3.go through the following site:-http://www.redhat.com/developer_studio/guides/jbpm/html_single/

4.After creating the definition copy the xml file in jbpm-web -> definitions folder in webs.

5.Change the biuld file in jbpm-web chnage the following
//------------------------------------------------------------------------------------------------------------------//






--- To ---




//-------------------------------------------------------------------------------------------------------------------//




--- To ---




//------------------------------------------------------------------------------------------------------------------//

6. And then perform the steps as for the previous jbpm-web


___________________________________________


Double entries Workflow Configuration

Workflow Configuration portlet

double entry fields

4.0.23 + MySQL 5. 6.1



Irshad Masuri