Archive for January, 2012

Displaying list of video files in liferay?

upload video file in document library click here

Show/Displaying  a list of video file:
Use Asset Publisher portlet.
To show only video files configure “Asset Publisher portlet” follow the below steps

a. Asset Type >> select Filter then remove all option other than “Document Library Document” in Current field.
b. Displayed assets must match these rules. >> selecting tag(video).
c. save the configuration.

Advertisements

How to upload .mp3/.mp4/.mov… files in Liferay?

To upload .mp3/.mp4/.mov … files follow the below steps.

Step1:

Add the below key in portal-ext.properties file

or

create a new hook portlet to overhide the portal.properties


#
# A file extension of * will permit all file extensions.
#
# You can map a GIF for the extension by adding the image to the theme's
# image display and document library folder. The wildcard extension of *
# will be ignored. For example, the default image for the DOC extension
# would be found in: /html/themes/_unstyled/images/document_library/doc.gif.
#
dl.file.extensions=\
.bmp,.css,.doc,.docx,.dot,.gif,.gz,.htm,.html,.jpg,.js,.lar,.odb,.odf,\
.odg,.odp,.ods,.odt,.pdf,.png,.ppt,.pptx,.rtf,.swf,.sxc,.sxi,.sxw,.tar,\
.tiff,.tgz,.txt,.vsd,.xls,.xlsx,.xml,.zip,.jrxml,.mp4,.mp3,.mov

Step2:

Upload the video files in document library add a tag video.

Hint: we are adding tag here to display only video file.

Displaying list of video files in liferay? check here

Liferay 6.1 in Android 2.1

Liferoid Lite

Click here

 

Liferay In Kannada language coming shortly…

Liferay In Kannada language coming shortly

Language Portlet

Dock

Control Panel

Generate PDF file using java

package com.liferay;

import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.util.Date;
 
import com.lowagie.text.Document;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;
 
public class GeneratePDF {
 
    public static void main(String[] args) {
        try {
            OutputStream file = new FileOutputStream(new File("E:/01_Installing-liferay-bundle.pdf"));
 
            Document document = new Document();
            PdfWriter.getInstance(document, file);
            document.open();
            document.add(new Paragraph("Hello Rajeeva Lochana.B.R"));
            document.add(new Paragraph(new Date().toString()));
 
            document.close();
            file.close();
 
        } catch (Exception e) {
 
            e.printStackTrace();
        }
    }
}

Create a URL based on PortletId in Liferay

Necessary package need to Import in JSP page
    <%@ page import="com.liferay.portlet.PortletURLFactoryUtil"%>
    <%@ page import="com.liferay.portal.kernel.portlet.LiferayPortletURL"%>
    <%@ page import="javax.portlet.PortletRequest"%>
    <%@ page import="javax.portlet.PortletURL"%>
    <%@ page import="javax.servlet.http.HttpServletRequest"%>

Syntax:

portletURL URL = PortletURLFactoryUtil.create(request, portletId, plid, lifecycle);

OR

LiferayPortletURL URL = PortletURLFactoryUtil.create(request, portletId, plid, lifecycle);

For creating PortletRequest URL


ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
LiferayPortletURL renderURL = PortletURLFactoryUtil.create(request, portletId, plid, PortletRequest.RENDER_PHASE);
renderURL.setWindowState(WindowState.NORMAL); //to set windowsState
renderURL.setPortletMode(PortletMode.VIEW);  //to set portletmode
renderURL.setParameter(arg0,arg1);  /to set the parameter ex:ipcActionURL.setParameter("struts_action",/etc/reports/add);

LiferayPortletURL actionURL = PortletURLFactoryUtil.create(request, "portletId", plid, PortletRequest.ACTION_PHASE);
actionURL.setWindowState(WindowState.NORMAL); //to set windowsState
actionURL.setPortletMode(PortletMode.VIEW);  //to set portletmode
actionURL.setParameter(arg0,arg1);  /to set the parameter ex:ipcActionURL.setParameter("struts_action",/etc/reports/add);

PortletId:
          To fetch the current portletId or portletName.

            portletDisplay.getId();
            portletDisplay.getPortletName();

plid (Portlet Layout id):
         We need to mention plid, based on this plid it will redirect that particular
         page.//for InterPortlet communication(IPC)

<%= LayoutLocalServiceUtil.getFriendlyURLLayout(themeDisplay.getScopeGroupId(), false, "/layoutName").getPlid() %>

OR

<%=themeDisplay.getPlid()%>

Lifecycle/PortletRequest:
         Two types of portlet request we can use here.

  1.   PortletRequest.RENDER_PHASE
  2.   PortletRequest.ACTION_PHASE
  3.   PortletRequest.EVENT_PHASE
  4.   PortletRequest.RESOURCE_PHASE
  5.   PortletRequest.LIFECYCLE_PHASE

Insert text into PDF file using java

Required jars:

  • itext-1.1.4.jar
  • itext-rups-2.1.3.jar
  • jdtaus-editor-client-application-1.0-beta-10.jar
  • PDFRenderer.jar

package com.liferay;

import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.InputStreamReader;

import com.lowagie.text.Document;
import com.lowagie.text.PageSize;
import com.lowagie.text.Paragraph;
import com.lowagie.text.pdf.PdfWriter;

public class TextToPDF{
public static void main(String arg[]){
try{
InputStreamReader in= new InputStreamReader(System.in);
BufferedReader bin= new BufferedReader(in);
System.out.println("Enter text:");
String text=bin.readLine();
Document document = new Document(PageSize.A4, 36, 72, 108, 180);
PdfWriter.getInstance(document,new FileOutputStream("E:/workspace/rnd/javarnd/pdfFile.pdf"));
document.open();
document.add(new Paragraph(text));
System.out.println("Text is inserted into pdf file");
document.close();
}catch(Exception e){}
}
}