Showing posts with label liferay custom portlet modes. Show all posts
Showing posts with label liferay custom portlet modes. Show all posts

Sunday, September 1, 2013

Connecting Liferay with Another Database

In the following post we will connect liferay with some third party database (legacy database):

Method 1:

1. Create Service.xml

2. Create ext-spring.xml file as /WEB-INF/src/META-INF/ext-spring.xml

You wont believe but yes we are done!!


Method 2:

1. Make an entry in portal-ext.properties file for another database:

2. create service.xml:

3. create ext-spring.xml file:


done!


NOTE: In both the above methods, we have to create the table manually in the database.

Tuesday, July 24, 2012

Liferay Custom Portlet Mode

 

The PortletMode class defines three constants—VIEW, EDIT, and HELP—corresponding
to the VIEW, EDIT, and HELP portlet modes. A portal may define support for additional portlet modes supported by the portal server or by the portlet.

 

Portal Managed Mode - If the portal server is responsible for managing the portlet mode, the portlet mode is referred to as portal-managed. Liferay provides config, about, print, preview and edit_defaults custom portlet modes.

Portlet Managed Mode - If the portlet is responsible for managing the portlet mode, it’s referred to as portlet-managed..

 

Implementing the Portal-managed Custom Portlet mode:

 

Here are the steps to implement print custom portlet mode provided by liferay

 

1. Define support in the portlet.xml -

We must specify the custom portlet mode in the portlet deployment descriptor using the <portlet-mode> subelement of the <supports> element

<portlet-mode>print</portlet-mode>

 

2. A custom portlet mode must also be defined at the portlet application level. The <custom-portlet-mode> subelement of <portlet-app> specifies the custom portlet modes that are available to portlets in the portlet application

<custom-portlet-mode>

<portlet-mode>print</portlet-mode>


</custom-portlet-mode>

 

3. Setting portlet mode in the URL

PortletURL printModeUrl = renderResponse.createRenderURL();
if(renderRequest.isPortletModeAllowed(new PortletMode("print"))) {
printModeUrl.setPortletMode(new PortletMode("print"));
}
request.setAttribute("printModeUrl", printModeUrl);

 

NOTE: if(renderRequest.isPortletModeAllowed(new PortletMode("print")))

above condition checks whether liferay provides support for print custom portlet mode. The PortalContext’s getSupportedPortletModes() method returns the list of portal-managed portlet modes.

 

4. Add link to switch to print mode

<href="<%=printModeUrl.toString() %>">Print Mode</a>


 

5. Implementing the custom portlet mode behavior -

In the portlet class override the doPrint method:

@Override
public void doPrint(RenderRequest renderRequest,
RenderResponse renderResponse) throws IOException, PortletException {
System.out.println("Print Mode Called");
super.doPrint(renderRequest, renderResponse);
}

 

**Liferay doesnt provide support for portlet-managed custom portlet modes.