Sunday, 21 February 2016

Create Project for Liferay Using commnad prompt

----------------- MAVEN PROJECT-----------------------

   mvn archetype:generate -DarchetypeGroupId=com.liferay.maven.archetypes -DarchetypeArtifactId=liferay-theme-archetype -      DarchetypeVersion=6.1.1 -DgroupId=groupIdOfMyTheme -DartifactId=NameOfMyTheme -Dversion=1.0.0-SNAPSHOT


------------------------ ANT PROJECT -----------------

create.bat hello-world "Hello World"

Wednesday, 11 November 2015

Including JSP page in Vm file


$theme.include($themeServletContext, "/elements.jsp")



make sure that elements.jsp page is available under root folder of theme

Wednesday, 4 November 2015

Adding Portlet in Control Panel

In liferay-portlet.xml .......write these two lines after <icon>/icon.png</icon> tag


       <control-panel-entry-category>configuration</control-panel-entry-category>

        <control-panel-entry-weight>1.0</control-panel-entry-weight>

 


 

Thursday, 29 October 2015

Embedding Portlet in Layout


--------------------------for custom portlet--------------------

                      $processor.processPortlet("aluminilanding_WAR_ATS_Aluminiportlet")

 

--------------------------Out of Box Portlets--------------------
                      $processor.processPortlet("58")

 

-------------------------Syntax---------------------------------

                         $processor.processPortlet("Portlet ID")

Friday, 16 October 2015

Embedding Web Content into Portlet

In Jsp page

<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%>

<liferay-ui:journal-article articleId="11550" groupId="10181"></liferay-ui:journal-article>

Embedding web content into theme

In portal-normal.vm file

#set ($articleId = '11550')

$theme.journalArticle($articleId, $themeDisplay.getSiteGroupId(), "")

Thursday, 1 October 2015

Service Locator

#set ($journalArticleLocalService = $serviceLocator.findService("com.liferay.portlet.journal.service.JournalArticleLocalService"))

#set ($journalArticle = $journalArticleLocalService.getArticleByUrlTitle($group_id,"footer_webcontent"))






#set($userLocalService = $serviceLocator.findService('com.liferay.portal.service.UserLocalService'))
$user.getFirstName()



#set ($VOID = $velocityPortletPreferences.setValue('groupId', $themeDisplay.getScopeGroupId().toString()))
#set ($VOID = $velocityPortletPreferences.setValue('articleId', '11475'))
#set ($VOID = $velocityPortletPreferences.setValue('portletSetupShowBorders', 'false'))
#set ($portlet_id = '56')
#set ($my_portlet_id = "${portlet_id}_INSTANCE_75LVKxT6OlOQ")
$theme.runtime($my_portlet_id, "", $velocityPortletPreferences.toString())
#set ($VOID = $velocityPortletPreferences.reset())



#set ($articleId = '11519')
$theme.journalArticle($articleId, $themeDisplay.getSiteGroupId(), "")

Sunday, 2 August 2015

Random Image Display using Web content in liferay

<script>
window.onload=function abc(){
   var description=[
                "$request.get("theme-display").path-theme-images/veteran/banner.jpg",
                "$request.get("theme-display").path-theme-images/veteran/1.jpg",
                "$request.get("theme-display").path-theme-images/veteran/2.jpg",
                "$request.get("theme-display").path-theme-images/veteran/3.jpg",
                "$request.get("theme-display").path-theme-images/veteran/4.jpg",
                "$request.get("theme-display").path-theme-images/veteran/5.jpg",
                "$request.get("theme-display").path-theme-images/veteran/6.jpg"
                ];
 var size = description.length

var x = Math.floor(size*Math.random())

var picture = $('.picture-tag');

var img = picture.next();

picture.attr('srcset',description[x]);

img.attr('src',description[x]);
}
</script>



<div class="banner_box ">
  <picture>
    <source srcset="$imageBannerSmall.getData()" media="(max-width: 766px)"                                  class="picture-tag">
         <img <img window.onload="abc()"/>
   </picture>
</div>

Thursday, 9 July 2015

Liferay Custom field and Expando Tables

Creating Extra Field

If you want to add extra field in liferay default table ......
 In 6.2
Admin-------------->control panel--------->Custom Fields---------->User

select entity for ex..User

User-------->Add Custom Field -------->Enter Key &  Type and save it 




Saving The Custom field value

 
in jsp page
 <%
      User currentUser = themeDisplay.getUser();
          %>
          <div class="control-group">
            <label for="reportingManager" class="control-label">Reporting Manager</label>
            <div class="controls">
              <liferay-ui:custom-attribute-list
              className="<%= User.class.getName() %>"
              classPK="<%= currentUser != null ? currentUser.getUserId() : 0 %>"
              editable="<%= true %>" label="false"/>
            </div>
          </div>   
in controller
  ServiceContext serviceContext = ServiceContextFactory.getInstance(User.class.getName(),      actionRequest);
    user.setExpandoBridgeAttributes(serviceContext);
    UserLocalServiceUtil.addUser(user);


After creating custom field ,it is available in ExpandoTable and ExpandoColumn

After Saving You can check it in ExpandoValue Table



 

Monday, 6 July 2015

Fetching Last Primary Key From Table

1.     SELECT qualityId FROM `quality_quality`
        ORDER BY qualityId DESC
        LIMIT 1;

2.     select max(qualityId ) from quality_quality"


3. In Liferay
         
          Quality qua = new QualityImpl();
           long siz1 = 0 ;
     try{
          long qualityId = ParamUtil.getLong(renderRequest, "qualityId");
         qua = QualityLocalServiceUtil.getQuality(qualityId);
      if(qualityId > 0)
        siz1 = qua.getQualityId();
}catch(Exception e){
    int size=l.size();
    if(size == 0){
         siz1 = 1;
         //out.print(siz1);
    }else{
          siz1 = ((l.get(size-1).getQualityId())+1) ;
          //out.print(siz1);
      }
}

Monday, 22 June 2015

How to create Folder in Java

import java.io.File;
 
public class CreateFolder
{
    public static void main(String[] args)
    { 
 File file = new File("C:\\Folder");
 if (!file.exists()) {
  if (file.mkdir()) {
   System.out.println("Folder is created!");
  } else {
   System.out.println("Failed to create Folder!");
  }
 }
 
 File files = new File("C:\\Folder1\\Sub1\\Sub-Sub1");
 if (files.exists()) {
  if (files.mkdirs()) {
   System.out.println("Multiple Folders are created!");
  } else {
   System.out.println("Failed to create multiple Folders!");
  }
 }
 
    }
}

Monday, 15 June 2015

Creating File in java

import java.io.File;
import java.io.IOException;

public class WriteInFile {

public static void main(String[] args) {
// TODO Auto-generated method stub
try {
File f = new File("d:\\newfile.txt");       // path to create file

if (f.createNewFile()){
System.out.println("file created");
}else{
System.out.println("file is their");
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

}

Sunday, 14 June 2015

Using custom properties file in jsp and java files for dynamic work(In Liferay 6.2)



 Properties prop = new Properties();
 FileInputStream inputStream = new FileInputStream("/path of the file");
 prop.load(inputStream);


U can keep properties file location src else tomcat bundle

Thursday, 11 June 2015

Embedding One portlet in Another (Liferay 6.2)

Write Below Lines in Jsp Page

<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>
 <liferay-portlet:runtime portletName="82" />


Where 82 is portlet Id 

Tuesday, 9 June 2015

Possible Data Types In Liferay Service Layer


  • String
  • Boolean
  • Date
  • long
  • Collection
  • int
  • double
  • Blob

How to Increase the size of Column in Liferay?

By Default Size of Column(Data type String ) is 75..

If We Want Increase this size write the sentence like below in portlet-model-hints.xml under
docroot/WEB-INF/SRC/META-INF


                 <field name="description" type="String">

<hint name="max-length">500</hint>

</field>


and build service.xml once......

Friday, 5 June 2015

Sorting Column in Search Container


  • Write orderable and orderableProperty for column like below


<liferay-ui:search-container-column-text name="Start Date" property="startDate" orderable="true" orderableProperty="startDate"/>


  •  Write render Method in controller class
@Override
public void render(RenderRequest request, RenderResponse response)
throws IOException, PortletException {
//System.out.println("hello1");
setSortParams(request);
super.render(request, response);
}

private void setSortParams(RenderRequest request) {
String jspPage = ParamUtil.getString(request, "jspPage");
//System.out.println("hello"+jspPage);
if (jspPage.equalsIgnoreCase(ProjectConstants.PAGE_PROJECT)) {
String orderByCol = ParamUtil.getString(request, "orderByCol",
"projectId");
request.setAttribute("orderByCol", orderByCol);
String orderByType = ParamUtil.getString(request, "orderByType",
"asc");
request.setAttribute("orderByType", orderByType);
//System.out.println("hello"+orderByCol+"aa"+orderByType);
}
}
  • In JSP Page
List<Projects> projects = ProjectsLocalServiceUtil.getProjectses(0, ProjectsLocalServiceUtil.getProjectsesCount());

String orderByCol = (String) request.getAttribute("orderByCol"); 
String orderByType = (String) request.getAttribute("orderByType"); 
BeanComparator comp = new BeanComparator(orderByCol); 
List<Projects> projectsResults = ListUtil.copy(projects);

Collections.sort(projectsResults, comp); 
//System.out.print("column:"+orderByCol);
//System.out.print("type:"+orderByType);
if (orderByType.equalsIgnoreCase("desc")) {
Collections.reverse(projectsResults); 
}

  • At Last add this attributes
<liferay-ui:search-container orderByCol="<%= orderByCol %>" orderByType="<%= orderByType %>" >
</liferay-ui:search-container>

Thursday, 4 June 2015

Interface Concept In java

INTERFACE


  • A Java interface is a bit like a class, except a Java interface can only contain method signatures and fields
  • An Java interface cannot contain an implementation of the methods, only the signature (name, parameters and exceptions) of the method.
  • You can use interfaces in Java as a way to achieve polymorphism.
For Exa.

public interface MyInterface {

    public String hello = "Hello";   //parameter
 
    public void sayHello();          // method signature
}

Sunday, 31 May 2015

Loops in Java


  • FOR LOOP

public class ForLoopExample {

public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("working");
for(int i=1; i<=50 ; i++){
int n = 2 * i;
System.out.println("2 * "+ i + " = " + n);
}
}

}



  • WHILE LOOP
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("working");
int i = 0;
while (i < 50) {
 i++;
 int m = i*2;
        System.out.println("2 * "+ i + " = " + m);
        }
}
}


  • DO WHILE LOOP
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("working");
int i = 0;
do {
 i++;
 int m = i*2;
        System.out.println("2 * "+ i + " = " + m);
        } while (i < 50);
}
}


OUTPUT:-
2 * 1 = 2
2 * 2 = 4
2 * 3 = 6
2 * 4 = 8
2 * 5 = 10
2 * 6 = 12
2 * 7 = 14
2 * 8 = 16
2 * 9 = 18
2 * 10 = 20
2 * 11 = 22
2 * 12 = 24
2 * 13 = 26
2 * 14 = 28
2 * 15 = 30
2 * 16 = 32
2 * 17 = 34
2 * 18 = 36
2 * 19 = 38
2 * 20 = 40
2 * 21 = 42
2 * 22 = 44
2 * 23 = 46
2 * 24 = 48
2 * 25 = 50
2 * 26 = 52
2 * 27 = 54
2 * 28 = 56
2 * 29 = 58
2 * 30 = 60
2 * 31 = 62
2 * 32 = 64
2 * 33 = 66
2 * 34 = 68
2 * 35 = 70
2 * 36 = 72
2 * 37 = 74
2 * 38 = 76
2 * 39 = 78
2 * 40 = 80
2 * 41 = 82
2 * 42 = 84
2 * 43 = 86
2 * 44 = 88
2 * 45 = 90
2 * 46 = 92
2 * 47 = 94
2 * 48 = 96
2 * 49 = 98
2 * 50 = 100

Friday, 22 May 2015

Liferay Interview Questions.....



1>Diff Between Hook And Ext?
2>what are the types of hooks?
3>mention the types of plugins in liferay?
4>explain service builder?
5>what is web content?
6>How to increase the size of column in liferay?
7>what are the possible DataTypes in Liferay?
8>How can you store image in Liferay Technology?
9>How To Embed One Portlet In another Portlet?
10>What is Liferay?
11>Diff Between 286 and 168 JSR Complaint?
12>What are users and usergroups?
13>explain IPC?
14>diff between dynamic query and custom query>
15>diff between liferay and other frameworks?
16>portal instance in liferay?
17>how to add portlet in control panel?