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

Sunday, September 24, 2017

How to delay Quartz Scheduler startup in a web application

Quartz scheduler startup can be delayed by configuration in web.xml or programmatically.

1. Configuration in web.xml
<context-param>
<param-name>quartz:start-delay-seconds</param-name>
<param-value>DELAY_IN_SECONDS</param-value>
</context-param>

2. Programmatically
    scheduler.startDelayed(DELAY_IN_SECONDS);


Done!!

Saturday, September 23, 2017

How to create angular 4 module

This tutorial assuming all prerequisite to start an Angular 4 application has been properly setup with Angular cli.

To create angular 4 module, follow the steps below.
1. navigate to the root directory of your Angular 4 application.

2. run the following command to generate a new module class
    ng generate module moduleName

    eg. ng generate module ferrari
3. run the following command to generate a new component under the above module
    ng generate component moduleName/componentName

    eg. ng generate component ferrari/ferrari-list
4. create a routing class in the same directory with module class  

    eg. ferrari-routing.module.ts



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!!

Monday, August 7, 2017

How to disable Chrome autofill with jQuery

To disable the Google Chrome autofill,
the solution is to set the autocomplete in the input element to off.
with the following jQuery function, all the input element in the page will be set autocomplete to off.

$(document).ready(function(){ 
    $("input").each(function () {
         $(this).attr("autocomplete", "off");
       })
})



Done!!

LinkWithin

Related Posts Plugin for WordPress, Blogger...