Showing posts with label Liferay. Show all posts
Showing posts with label Liferay. Show all posts

Wednesday, October 18, 2017

How to easily get logged in user in Liferay.



ServiceContextThreadLocal.getServiceContext().getUserId();


reference:
http://liferay-hacks.blogspot.my/2014/01/get-current-logged-in-user-easily-in.html

Wednesday, August 16, 2017

Quick access to httpSession in Liferay

The following syntax can access to Http Session Object in Liferay without going through PortletSession Object.

Setting session object

PortalSessionThreadLocal.getHttpSession().setAttribute("sessionAttributeName", value); 



Retrieving session object by key 

PortalSessionThreadLocal.getHttpSession().getAttribute("sessionAttributeName");




Done!!

Thursday, June 22, 2017

Quick Start Angular 2 module in Liferay

Platform:
Angular 2
Liferay 6.x, Liferay 7

Steps
1. download the sample project done by devsoftcz from github

2. extract the sample project, and change the project folder name.

3. open bnd.bnd, change the Bundle-SymbolicName to desired name

4. open package.json, change the "name" and "description" in the top part.

Monday, May 22, 2017

How to add ui-bootstrap in AngularJS Portlet

Platform:
Liferay 6.x, 7.x
AngularJS 1.6.x

To addui-boostrap into AngularJS, we will reuse the AngularJS portlet created earlier with ui-router.

Steps to add ui-bootrap are pretty simple, we just need to import ui-bootstrap-tpls-2.5.0.min.js in view.jsp

<script src="https://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-2.5.0.min.js" />



and also bootstrap.min.css

<link href="//netdna.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>


Lastly, we can start using bootstrap components by referring the bootstrap demo page.


Done!!

Tuesday, May 16, 2017

How to use ui-router in AngularJS Portlet

Platform:
- Liferay 6.x, Liferay 7.0
- AngularJS 1.6.x

In this example, we will also continue from the first angularJS portlet created in earlier post.
the differences with the ngRoute example are main.jsp

Steps
1. create 2 new jsp for the ui-routing example in the same folder with view.jsp
- page1.jsp, with the following content

<h2>This is the page 1.</h2>


- page2.jsp, with the following content

<h2>This is the page 2.</h2> 


Thursday, May 11, 2017

How to use ngRoute in AngularJS Portlet

Platform:
- Liferay 6.x, Liferay 7.0
- AngularJS 1.6.x

In this example, we will continue from the angularJS portlet created in earlier post.
1. create 2 new jsp for the routing example in the same folder with view.jsp
- first.jsp, with the following content.

<h2>This is the first page.</h2>


- second.jsp, with the following content

<h2>This is the second page.</h2>



Saturday, May 6, 2017

How to create AngularJS portlet in Liferay

Platform:
- Liferay 6.x, 7.0
- AngularJS 1.6.x

Hello World in Liferay Angular Portlet
1. create liferay plugin with liferay mvc portlet tempalte
File > New > Other > Liferay > Liferay Plugin Project > Next
    Fill in "Project name" > Finish.

Tuesday, April 18, 2017

How to run Liferay blade in windows 10

1. download blade.jar from Liferay.

2. open the command prompt, and navigate to the downloaded blade.jar directory.

3. type the following command in the command prompt

java -cp blade.jar com.liferay.blade.cli.blade create -d path/of/the/liferay/module portlet




Done!!

Sunday, March 19, 2017

How to configure Liferay Language portlet as Select Box

 Image above shown the default Liferay Language portlet.

to change the default display option, please follow the steps below.
1. Login to Liferay as Administrator

2. navigate to the portlet setting to open the Language configuration.

Friday, March 17, 2017

How to post json to Liferay OSGI restful service


To post a json to a Liferay OSGI restful service,
the service method itself must be able to accept String as the input parameter.
the service method is then parse the json string to a json object
follow by the required function process
and lastly return the response to the service consumer


@POST
@Path("/addPerson")
@Consumes(MediaType.APPLICATION_JSON) 
@Produces(MediaType.APPLICATION_JSON)
public Response addPerson(final String personJsonString) {

    ObjectMapper mapper = new ObjectMapper();
    JsonNode personJson = mapper.readTree(personJsonString);

    /**
     * Process person json 
     * 
     */
    
    return Response.status(Response.Status.OK).build();
}



Done!!

Wednesday, September 21, 2016

How to activate / inactivate Portlet in LIferay

1. Login as Liferay Administrator

2. Navigate to Plugins Configuration
    Control Panel > Apps > Plugins Configuration

3. Click on 1 of the plugin from the list, eg. Documents and Media

4. untick the "Active" checkbox.

5. Save.

With these steps, the Documents and Media portlet/plugin has been deactivated.


Done!!

Monday, December 14, 2015

Google Maps' icon not rendered in Liferay 6.2

When using Google Maps in Liferay  6.2.
All the icon in Google Maps are not rendered,
This is due to css conflict in Liferay 6.2 and Google Maps.

To resolve this problem, just need to add the following css.
.aui .gm-style img {
  max-width: none;
}


Done!!

Thursday, October 23, 2014

How to check system configured properties in Liferay

There are a lot of  properties/attributes configured in Liferay.
All these configured System Properties and Portal Properties could be accessed through Server Administration.

1. Login as Liferay Administrator

2. Liferay 6.1.x
    Go to > Control Panel > Server > Server Administration > Properties

Tuesday, October 14, 2014

How to shutdown Liferay with warning and timeout to the users

There is a smarter way to shutdown Liferay.
Where Liferay allowed the system administration to enter the shutdown time and warn all logged in users regarding shutdown of the Portal.
Thus, all logged in users can quickly save their works without losing any data.

Platform: Liferay 6.2.x

Steps:
1. Login as Liferay Admin
2. Admin > Control Panel > Configuration > Server Administration > Shutdown

Thursday, August 7, 2014

Liferay admin password used in Liferay Web Service

Recently discovered that the Liferay admin's password used for the Liferay remote services.
must be without "@".

Liferay API will extract from "@" until the "/" to be the target service host.

eg. adminPassword@127.0.0.1:8080/api/axis
meaning from the above example, 127.0.0.1:8080 will be extracted as the target host.

somehow if the adminPassword contains "@", the API will extract from the adminPassword.

eg: adminP@ssword@127.0.0.1:8080/api/axis
now the host becomes @ssword@127.0.0.1:8080.

with this adminP@ssword, Liferay API will throw an unknownHostException.

conclusion, @ not allowed in the Liferay Admin password to be used in Liferay web service.


Done!!

Sunday, July 6, 2014

How to get Company Id in Liferay

To check company Id in Liferay, we can check from Portal Instance

1. Login as Liferay Administrator.

2. Go to > Control Panel > Server > Portal Instance


Last but not least, the default Company ID in Liferay 6.1.x is 1, default Company ID in Liferay 6.2.x is 10157.


Done!!

Wednesday, May 14, 2014

How to change Liferay Portlet title with jQuery

In some cases, we might want to change the Portlet title, So that the title is more meaningful the the Portlet content.
eg. screen navigates from search page to maintenance page.


$('#idOfDeployedPortlet').find('.portlet-title-text').html('new title');


idOfDeployedPortlet - portlet id deployed in Liferay, if you do not know how to get the deployed portlet id, please refer this post.
new title - Title to be passed in for the target page.

Friday, April 25, 2014

How to define Category for custom portlet in Liferay

When we deploying portlets into Liferay portal, somehow we need to define new Category Name for our customized portlets instead of just place all the portlet under Sample.
Below are the steps how to define new Category in Liferay portal.

1. Open liferay-display.xml
<?xml version="1.0"?>
<!DOCTYPE display PUBLIC "-//Liferay//DTD Display 6.1.0//EN" "http://www.liferay.com/dtd/liferay-display_6_1_0.dtd">

<display>
 <category name="category.sample">
  <portlet id="primefaces" />
 </category>
</display>

Thursday, April 17, 2014

Possible ways to hide/show Portlet border in Liferay

There are several ways to hide/show portlet border in Liferay.
1. Configure in every portlet.
To show/hide portlet border in every individual portlet, detailed steps shown in previous post.

2. Configure in theme;
All portlets within the configured theme will be show/hide border by default.
add the following line into liferay-look-and-feel.xml
the value is either true or false.
<theme id="myTheme" name="myTheme" >
    <settings>
        <setting key="portlet-setup-show-borders-default" value="true|false" />
    </settings>
     .............................................
     .............................................
</theme>

3. Configure in portal-ext.properties;
All portlets will be show/hide border by default
add the following line into portal-ext.properties
the value is either true or false.

theme.portlet.decorate.default=true|false



Done!!

Wednesday, March 26, 2014

How to generate styled PDF in Liferay PrimeFaces Portlet with iText

In the previous post,
How to generate PDF in Liferay PrimeFaces Portlet with iText shows how to generate a PDF document, unfortunately, the generated PDF is not able to handle style class.

eg,
<!DOCTYPE HTML><html><body>Generate <strong>PDF</strong> Test</body></html>
can be generated without any problem. 

but, 
<!DOCTYPE HTML><html><body>Generate <span style='color: red;'>PDF</span> Test</body></html>
is unable to generate the text with red color.

LinkWithin

Related Posts Plugin for WordPress, Blogger...