Pages

Tuesday, March 24, 2009

Getting POPUP in Liferay application

Using Pop-up in Liferay

When developing portlets in Liferay there are two ways to implement pop-ups. We can use a Floating Div or the traditional new browser Window without the toolbars. Each of them has got their advantages so we will have to decide which one fits us better. For example, if you are using a pop up with a form, you won't be able to send files attached to the form if you are using a floating div.

In this article there are some tips to develop both types of pop-ups.

Floating Div Pop-Up

Liferay provides a class called Expanse.Popup to implement this type of pop ups. Here is how this type of pop up would look like:

One advantage of this type of pop up is that they are invisible to pop up blockers (although that could change as they get smarter). This javascript code will make an asynchronous call to the url we give it and will place the content in our page. Below there is an example which will load the url 'url' in a pop up called 'our title':

var popup = new Expanse.Popup(
{
header: 'our title',
position:[150,150],
modal:true,
width:500,
height:300,
xy: ['center', 100],
url: 'url',
urlData: {
parameter1: 'value1',
parameter2: 'value2'
}
}
);
It's important to note that if the url is a portlet url it must have the windowState parameter set to LiferayWindowstate.EXCLUSIVE, because we just want the content produced by the portlet and not the extra portlet decoration produced by the portal.

To implement a button or link to close the pop up use the following code:

Expanse.Popup.close(this);

This type of pop-up is used in several Liferay core portlets like the image gallery (show pictures), journal (edit template) or my communities (publish to live). Look at them for further examples of usage.

Window Pop up

This type of pop ups will load in a new window. In order to do that we must set the windowState parameter in the portlet url to LiferayWindowState.POP_UP. This windowState will produce that the result of calling a portlet url will be shown in another window, like a real pop up. There are no visual effects asociated, it's a different window.

However, from this window we can still make javascript calls to the parent page javascript functions as the javascript object opener refers to the parent window. There is an example below:

--lt--input value="select" onclick="  var organizationWindow = window.open('    <%= LiferayWindowState.POP_UP.toString() %>">


',
'title',
'directories=no, height=640, location=no, menubar=no, resizable=yes,
scrollbars=yes, status=no, toolbar=no, width=680');

organizationWindow.focus();" / --gt--

If we want to close the pop up we just need to do the following:

 window.close(); 

If we want to close the parent page we can do the following:

opener.close(); 

This is used in several portlets like the image gallery (show slideShow), enterprse admin (select organizations for users...)

Friday, March 20, 2009

To run videos in your web page

Here i am using window media player plug-in as to play videos.

you need to just copy the below object code in your html file.

- lt-object id="mediaPlayer" width="320" height="260" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject"-gt-
- lt-param name="url" value="/hmtv.wpl"-gt-
- lt-param name="uiMode" value="full"-gt-
- lt-param name="autoStart" value="true"-gt-
- lt-param name="playCount" value="9999"-gt-
- lt-param name="wmode" value="transparent"-gt-
- lt-embed type="application/x-mplayer2" pluginspage="http://microsoft.com/windows/mediaplayer/en/download/" showcontrols="1" uimode="full" wmode="transparent" width="320" height="260" src="/hmtv.wpl" autostart="1" playcount="9999"-gt-
- lt-/object-gt-


here i am using .wpl(window play list) which contains the list of wma files.
the .wpl file is looks like this..

- lt-?wpl version="1.0"?-gt-
- lt-smil-gt-
- lt-head-gt-
- lt-meta name="Generator" /-gt-
- lt-author/-gt-
- lt-title-gt-Playlist4- lt-/title-gt-
- lt-/head-gt-
- lt-body-gt-
- lt-seq-gt-
- lt-media src="AVSEQ01_3_clip0.wmv" /-gt-
- lt-media src="Griffey_Ken_WMV.wmv" /-gt-
- lt-media src="AVSEQ01_5_clip0.wmv" /-gt-
- lt-media src="AVSEQ01_7_clip0.wmv" /-gt-
- lt-media src="AVSEQ01_6_clip0.wmv" /-gt-
- lt-media src="AVSEQ01_8_clip0.wmv" /-gt-
- lt-/seq-gt-
- lt-/body-gt-
- lt-/smil-gt-

( plz replace -lt- with '< ' and -gt- '>')


thats it you can run your own video's using simple object script in html pages itself.

I hope this will be helpfull post for the people.

Wednesday, March 18, 2009

You do not have the roles required to access this portlet.

"You do not have the roles required to access this portlet." if you are getting this error while showing the portlets in your pages. You can hide them by setting

layout.show.portlet.access.denied=false in portal.properties file.

by default its value is true.

Struts Portlet example

If you want to develop portlets using Struts with existing liferay Struts action servlet then please go through this URL.


http://docs.liferay.com/portal/4.2/official/liferay-portlet-development-guide-4.2/multipage/ch03s02.html

PortletURL

This tutorial demonstrates how to get a Portlet to link back to itself within a JSP or even with the HTML code spit out within the doView method of a Portlet. The key is the PortletURL object... T...

URL :http://www.youtube.com/watch?v=SUlgKvWaZwo



Tuesday, March 10, 2009

Liferay

Liferay Portal provides jQuery as the default javascript library. This tutorial demonstrates how to build Standard tabbed page for your portlet using the jQuery library's tabs() method.

URL: http://www.youtube.com/watch?v=QBeomic29uc