Tuesday 5 November 2013

Accessing the site private and public page in Theme.

Fallow the bellow steps to access site private and public pages in theme.

1. #foreach($site in $user.mySites) ------- # end,
loop user site to get the site information to which the user belongs to,

2. as i explained in my previous to the bellow line of code will give you the LAYOUTLOCALSERVICEIMPL calss to access all the method in this class.   

#set ($layoutLocalService = $serviceLocator.findService("com.liferay.portal.service.LayoutLocalService"))

3. bellow line of code will give you the public and private layouts of the particular site

#set ($globalLayouts_private = $layoutLocalService.getLayouts($group.groupId, true, 0))

#set ($globalLayouts_public = $layoutLocalService.getLayouts($group.groupId, false, 0))
 
in the above line of code.
   a. layoutLocalService is the localLayoutServiceImpl class object.
   b. getLayouts is the method in the localLayoutServiceImpl class to get the public and private layout information
    c. argument  $group.groupId is the site id, you can get the group information through user object.
        ex:  $group in $user.getGroups(), 
       Note: don't get confuse group is nothing but site. 
   d. argument Boolean value is for accessing private or public page information
       ex: true is for public and false is for private
 
4 . than iterate the $globalLayouts_private & $globalLayouts_public this will contain the private and public site page information.

ex: 1.  #foreach ($private_layout in $globalLayouts_private)
      <a href="$portalUtil.getLayoutFriendlyURL($private_layout, $heme_display)"   $private_layout.getTarget()>$private_layout.getName($locale)</a>
         #end

     2. #foreach ($public_layout in $globalLayouts_public)
                                                        <a href="$portalUtil.getLayoutFriendlyURL($public_layout, $theme_display)" $public_layout.getTarget()>$public_layout.getName($locale)</a>
                                                                    #end     



I hope this blog may help you.......................



 

  
     



Monday 28 October 2013

Accessing custom service in theme

Follow the bellow steps to access Custom Service in liferay Theme.

1. Build your service and deploy the portlet into liferay portal.

2. set the bellow portal property value empty, by default it holds serviceLocator

journal.template.velocity.restricted.variables=

3. in vm file where you want to access the service, write the bellow line of code
 
#set($customLocalService=$serviceLocator.findService('your portlet name'),'package.entityLocalservice')

in the above code
  i.customLocalService  is the Custom Variable (User Defined)
  ii. your portlet name is the portlet name,  if you mentioned the portlet name means it will help the service locator to to find the service with in the portlet, ( i.e the portlet name you mentioned), if you pass empty values than service locator will search the service with portal.
 iii. Package is the package path of the service
 iv. entityLocalservice is the local service name

4.after the step 3, variable customLocalService,  will hold the reference of localservice impl class by using this you can access all the method in local service impl class.

I hope this blog may help you............................

Monday 18 February 2013

Changing portlet title dynamically at run time.

This Blog is to explain how to change the portlet title dynamically at run time. This can be done in two ways one in client side and other one in server side.

1. In server side you can do it by using render response object in your do-view method 
  exmple:=> renderResponseObject.setTitle("Give your choice title here");

2. in client side you can change it by using bellow java script function.
 example: 
document.getElemetById("portlet-id").getElementsByTagName("span")[1]. innerHTML="Give your choice title here";

add the above code into your xhtml or jsp page that is your view page, when page is loaded.means write inside onpage load function

Here in above client side code, to get portlet id in your liferay portal go to---> settings-->advance Styling, there you can find portlet id, copy and paste it in place of portlet id. copy portlet id after #symbol

Monday 31 December 2012

JSF Hello World Portlet In Liferay With Eclipse IDE

1.Go through the blog to integrate the Liferay portal with Eclipse IDE.

2.After integration done, set your Eclipse with Liferay Perspective.

3.For creating JSF Portlet go to File-->New-->Liferay Project, than you will get bellow window, in that Enter Project Name, Display Name and make sure the configuration and than select plugin type as portlet.
                                                                             Fig-1.
4. click next than you will get the bellow window, in that select JSF as your portlet frame work.
                                                                        Fig-2.
5. than click on finish.

6.after the step 5, you created your JSF Hello wold Portlet, than in your portal project open the PORTLET.XML file.
                                                                   Fig-3.

7.in portlet.xml file chage view-template to javax.portlet.faces.defaultViewId.view under the init param tag. 

8.in xhtml page portletViewMode.xhtml under the folder xhtml , type the hello world message.

9.after this do ant build, than logon to portal server, this HelloWorld portlet is available in in the category sample, than add this to your portal page.

Saturday 1 December 2012

Creating A Portlet Using Eclipse IDE And Deploying into Liferay Portal

1.For Step to Integration of Liferay Portal and SDK Plug in with Eclipse  Click Here.

2.After successfully  Integration of  Liferay portal with SDK Plug in with Eclipse.

3.Set for Liferay prospective, for this click on Window-->Open prospective-->Other--> liferay.

4.Than after this Start Liferay Server, by right clicking on sever-->start

5.Than Click on file-->new-->Liferay Project, Liferay Project creation wizard will open.
                                                  Fig-1. Liferay Project Creation Wizard

6.In the project creation window (Figure-1)Enter the Project name and select plug in type is Portlet. (and importantly check in configuration is pointed to SDK plugin and  Liferay portal).


7. after step 6 click on next, than will get next window as bellow, in that select portlet frame work as Liferay MVC in Select portlet framework and in additional option section checked the option of create custom portlet class. than click next.
                                                                      Figure-2

8.After clicking next, the next window as shown bellow will come,in that enter the name of portlet class, java package and select super class MVCPorlet or GenericPortlet class.(the difference between these two class is MVCPortlet class extends GenericPortlet class, Generic Portlet Class is Implements Portlet Interface). after this click next
                                                                          Fig-3

9.after step 8, will get next window show bellow, in that enter the portlet name,Display name, Title in portlet info section, you can select the portlet mode in portlet modes section and also you can select the Liferay modes also if you want in liferay portlet mode section, and in resource section checked the create jsp file and create resource bundle file,after that click next
Note: all the entry what you enter is available in portlet.xml
                                     
                                                                        Fig-4
10. after step-9, in the next window shown bellow, file the Liferay Portlet info and Liferay Display section,in Liferay display section you mention the category in which your portlet should display or you enter your category name also inside the text filed(drop down), in liferay portlet info section you can make your portlet as multiple instances in single page or single instance by checking or unchecking check box.
Note:1. Liferay Portlet info section entry what you enter is available in Liferay-portlet.xml
           2.Liferay Display section entry avilable in Liferay-display.xm


                                                                  Fig-5
11.after in the next window click on finish.

12. after in your project navigate to docroot-->html-->(folder name you enter in fig-4)-->view.jsp.
      in side view.jsp write helloword or if you want create a form.
      Note: if create form in view.jsp, write the process action method inside portlet class if your class extend MVCportlet class, or if your class extend Generic Portlet write logic in process action method.

13.after this do ant build and than log in to portal server and add your portlet to you portal page, by clicking on add-->more--->your category-->your portlet.

                                                                     Fig-6