Posts

Opening portlet in popup

  Sometimes, we may get requirements to open portlet in a popup. We can use below Javascrpit function to open in apopup. AUI().use('aui-base','aui-component','aui-parse-content','aui-node','liferay-form',     'liferay-portlet-url', 'liferay-util-window', 'plugin','aui-io-request', function(A){                    var renderURL = Liferay.PortletURL.createRenderURL();       renderURL .setWindowState("exclusive");        renderURL.setPortletId(" <portlet-name> ");       var  url = renderURL.toString();             A.io.request(url, {                 on: {                  success: function(event, id, obj) {                        var responseData = this.get('responseData');                        if (responseData) {                              Liferay.Util.openWindow({                                                                                               dialog: { 

Redirecting Post Values from Third Party application to Liferay

  Whenever we do Post in Liferay, Liferay will auto generate P_auth token.  But whenever we are doing posting(Post Request) from third party application and redirecting to Liferay application ,  liferay application will expect p_auth token. But third party applications cannot provide p_auth as it is Liferay specific.  But in liferay, we can design to ignore p_auth token for specific URL. First , Write a below class to ignore Auth token for specific URL @Component( immediate = true, property = { "auth.token.ignore.mvc.action=true", "javax.portlet.name=" + SamplePortletKeys.PortletName, "mvc.command.name=/redirect/liferay" }, service = MVCActionCommand.class ) public class RedirectPath extends BaseMVCActionCommand { } Here we have created MVCActionCommand Class  auth.token.ignore.mvc.action=true                This Property will ensure to ignore p_auth token.      2.  "mvc.command.name=/redirect/liferay"             Here we

Run geckodriver before launching the browser

  Inorder to launch empty firefox browser,just create a object to browser class,it automatically launches a browser,bcoz constructor has the code to launch empty browser. get() is used to navigate to any web application URL,but URL should start with "http:" or "https:" Note: Webdriver internally uses http or https protocol for browser communication. Example as below: import org.openqa.selenium.firefox.firefoxDriver; public class SampleFirstTest {               System.setProperty("webDriver.gecko.Driver",c://....path u should give");              FirefoxDriver driver=new FirefoxDriver();              driver.get("https://facebook.com");    } Webdriver basic Browser operation:      get()    navigate().to()    navigate().refresh();    navigate().back()    navigate().forward()    findElement()    findElements()    getTitle()    getCurrentUrl()    getPageSource()    getWindowHandles()    quit()    close()    ma

Organization Administrator and Organization Owner

Image
In Liferay, we can assign the users to the Organization and can assign the Organization role to the users. There are 3 types of organization roles . After assigning the role ,  If we want to fetch the users who has the Organization administartor. Below is the code. long orgId = ParamUtil.getLong(request, "organizationId"); List<User> users = OrganizationUtil.getUsers(orgId); Group organizationGroup = OrganizationLocalServiceUtil.getOrganization(orgId).getGroup(); for(User user: users){   long organizationGroupId = organizationGroup.getGroupId();   if (UserGroupRoleLocalServiceUtil.hasUserGroupRole(   user.getUserId(), organizationGroupId, RoleConstants.ORGANIZATION_ADMINISTRATOR)) {                   System.out.println("User is: "+ user);                                   } } First, we are fetching the users with Organizationid, Using that Organization, we are fetching the "Group" ,

Theme display in javascript

We know that we can access the themedisplay in java as ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY) But how can we access in javascript? Here we go Liferay.ThemeDisplay.getScopeGroupId() Liferay.ThemeDisplay.getCompanyId() Liferay.ThemeDisplay.getPlid() Liferay.ThemeDisplay.getLayoutId() By this we can access the groupId, companyid ... etc

Get Text from language properties via javascript

We know that we can get the text from the properties as   Language.properties     you-have-processed-sucessfully = Your Request processed successfully.   JSP: <liferay-ui : message key = "you-have-processed-sucessfully" /> CLASS: LanguageUtil . get ( pageContext , " you-have-processed-sucessfully " ); But if want to retrieve via javascript , Here is the one <script>      <custom code> ---               ----     Liferay . Language . get ( ' you-have-processed-sucessfully ' ); </script> But this Liferay.Language will get from the Portal properties not from the portlet properties There is way to solve this problem writing Hook and specifing the properties.

Introduction to Selenium

Image
Selenium is a free (open source) automated testing suite for web applications across different browsers and platforms. Different languages support by selenium Java PHP Perl Python C# ObjectC Ruby Javascript Selenium Versions Selenium IDE ( I ntegrated D evelopment E nvironment) Selenium RC ( R emote C ontrol) Selenium Webdriver Latest version is  Selenium Webdriver Selenium IDE  Implemented by shinya from JAPAN  Released in 2006  Functional  Automation tool supports only webapplications It is UI based and record/playback tool It is implemented plugin or add-on for the firefox browser Supports only firefox browser Selenium RC Implemented  by jsonhuggins from thoughtwork company Released in 2004 First automation open-source tool in the market It is Collections of javascript's. It's not a UI based, it doen't contain record/playback feature It Supports all browser and platform's Selenium Webdriver Implemented by