Wednesday, 27 January 2016

Display image in server using portal.vm

Explanation: In this we just have a scenario , that how we can display an image using liferay_portal.vm
In this docroot, under docroot dff folder is there placed any image in image folder.
then open the liferay-portal.vm and put this code




                                           <mark>hello</mark>                                                   $images_folder                                                               <br><br>

                     <img src="$images_folder/image.png">


here $image_folder means _dff/image
image.png is the image that we have to display.




                                                                       hope this helps you...






Wednesday, 20 January 2016

implicit objects in Liferay

     
                                        implicit objects in jsp 

1:-  request           (javax.servlet.ServletRequest)
2:-  response         (javax.servlet.ServletResponse)
3:-  out                  (javax.servlet.jsp.JspWriter)
4:-  pageContext    (javax.servlet.jsp.PageContext)
5:-  session            (javax.servlet.http.HttpS)
6:-  application      (javax.servlet.ServletContext)
7:-  config             (javax.servlet.ServletConfig)
8:-  page                (java.lang.Object)
9:-  exception      (java.lang.Throwable)





implicit objects in liferay portlet

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />

<portlet:defineObjects />
actionRequest (javax.portlet.ActionRequest)
actionResponse (javax.portlet.ActionResponse)
eventRequest (javax.portlet.EventRequest)
eventResponse, (javax.portlet.EventResponse)
portletConfig, (javax.portlet.PortletConfig)
portletName, (java.lang.String portletName)
portletPreferences, (javax.portlet.PortletPreferences)
portletPreferencesValues, (java.util.Map)
portletSession, (javax.portlet.PortletSession)
portletSessionScope, (java.util.Map)
renderRequest, (javax.portlet.RenderRequest)
renderResponse, (javax.portlet.RenderResponse)
resourceRequest, (javax.portlet.ResourceRequest)
resourceResponse (javax.portlet.ResourceResponse)



Theme implicit objects in liferay

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

1:-    themeDisplay             (com.liferay.portal.theme.ThemeDisplay)
2:-    company                   (com.liferay.portal.model.Company)
3:-    account                   (com.liferay.portal.model.Account)
4:-    user                        (com.liferay.portal.model.User)
5:-    realUser                 (com.liferay.portal.model.User)
6:-    contact                  (com.liferay.portal.model.Contact)
7:-    layout                      (com.liferay.portal.model.Layout)
8:-    layouts                    (java.util.List)
9:-    plid                            (java.lang.Long)
10:-  layoutTypePortlet        (com.liferay.portal.model.LayoutTypePortlet)
11:-  scopeGroupId             (java.lang.Long)
12:-  permissionChecker        (com.liferay.portal.security.permission.PermissionChecker)
13:-  locale                        (java.util.Locale)
14:-  timeZone                 (java.util.TimeZone)
15:-  theme                         (com.liferay.portal.model.Theme)
16:-  colorScheme              (com.liferay.portal.model.ColorScheme)
17;-  portletDisplay           (com.liferay.portal.theme.PortletDisplay)
18:-  portletGroupId           (java.lang.Long)



                                         hope this helps you...

how to make instance in portlet for multiple use in server


Explanation: In this generally how we can make a instance of portlet, likewise
if we click on sample in liferay server and if we click one portlet then the portlet will display but if we
click one more time it will not take for that solution we can make a instanceble for this portlet

                                         ..just go to liferay-portlet.xml 

                                       put this code

                          <instanceble>true<instanceble>


                                                              hope this helps you...

Tuesday, 19 January 2016

Liferay 6.2 CE GA6 Now Available

  You can download the 6.2 CE GA6 from the link given !!!!

                                      Link_to_the_Liferay 6.2 CE GA6


                                                hope this helps you...

Avoiding Multiple Submits

whenever we are submiting a form likewise registration page ,
after the submit the form will stored and also top url is there , when we click and enter once again then  it will automatically submit the values once again  .
 then to avoid this one write this code in liferay-portlet.xml
 below <icon> tag


<action-url-redirect>true</action-url-redirect>




                                          hope this helps you...

Monday, 18 January 2016

Liferay Top Contributor Award Q4 2015

Its a previlege and feel very proud to get a award from the liferay community and liferay moderator james falkner . A very very thank for them ! 

https://dev.liferay.com/participate/contributors

https://www.liferay.com/web/james.falkner/blog/-/blogs/2015-q3-q4-top-contributors-and-what-comes-next

























CRUD Operations in Liferay Portlet


Explanation:-In this article we will explain how to  perform CRUD Operations in Liferay Custom portlet. We will also explain the how to use service builder tool to perform all the operations one by one. At the end of this blog we will understand how to perform Create, Read, Update , Delete and Search Operations on Liferay Entity.


Step1:- create a portlet named as"registrationform".


Step2:-create a service builder as shown in figure.

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.2.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_2_0.dtd">

<service-builder package-path="com.reg">

<author>E00012</author>

<namespace>C</namespace>



<entity name="Student" local-service="true" remote-service="true">



<!-- PK fields -->



<column name="studentId" type="long" primary="true" />



<!-- Audit fields -->


<column name="firstname" type="String" />

<column name="lastName" type="String" />

<column name="branch" type="String" />

        <column name="age" type="int" />

        <column name="email" type="String"></column>     


</entity>

</service-builder>





Step3:- Now build the service and after that create a package,class and jsp as shown in the figure.





Step4:- In view.jsp write the code 

Note- you can download the code from the given link at the bottom.

<%@page import="javax.portlet.PortletURL"%>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />
<liferay-theme:defineObjects />
<h1>Registration form submission</h1>

<%
PortletURL addStudent = renderResponse.createRenderURL();
addStudent.setParameter("mvcPath", "/html/regform/add_student.jsp");
PortletURL updateStudent = renderResponse.createRenderURL();
updateStudent.setParameter("mvcPath", "/html/regform/update_by_id.jsp");
PortletURL dislayStudent = renderResponse.createRenderURL();
dislayStudent.setParameter("mvcPath", "/html/regform/display_student.jsp");
PortletURL updateStudentURL=renderResponse.createRenderURL();
updateStudentURL.setParameter("mvcPath", "/html/regform/update_student.jsp");
PortletURL searchByName=renderResponse.createRenderURL();
searchByName.setParameter("mvcPath", "/html/regform/search_by_name.jsp");
%>
<br/>
<a href="<%=addStudent.toString()%>">Add Student</a><br/>
<a href="<%=updateStudent.toString()%>">Update Student</a><br/>
<a href="<%=dislayStudent.toString()%>">Display Student</a><br/>
<a href="<%=searchByName.toString()%>">Search</a>


Step5:- create a add_student.jsp 


<%@page import="javax.portlet.ActionRequest"%>
<%@page import="com.liferay.portal.kernel.portlet.LiferayPortletMode"%>
<%@page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%>
<%@page import="javax.portlet.PortletURL"%>
<%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet"%>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme"%>
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%>
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui"%>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>

<portlet:defineObjects />
<%-- <portlet:renderURL var="homeURL"></portlet:renderURL>
<portlet:actionURL var="addStudentActionURL" windowState="normal"
name="addStudent">
</portlet:actionURL> --%>

<%
 PortletURL homeURL = renderResponse.createRenderURL();

    PortletURL addStudentActionURL = renderResponse.createActionURL();
 addStudentActionURL.setParameter(ActionRequest.ACTION_NAME, "addStudent");
%>
<h2>Add Student Form here !</h2>
<a href="<%=homeURL.toString()%>">Home</a>
<br />
<br />
<aui:form action="<%=addStudentActionURL.toString()%>" name="studentForm" method="POST">

<aui:input name="firstName" >
 <aui:validator name="required"/>
 <aui:validator name="alpha"/>
</aui:input>

<aui:input name="lastName" >
 <aui:validator name="required"/>
 <aui:validator name="alpha"/>
</aui:input> 

<aui:input name="branch" >
 <aui:validator name="required"/>
 <aui:validator name="alpha"/>
</aui:input>

<aui:input name="age">
 <aui:validator name="required"/>
 <aui:validator name="alpha"/>
</aui:input>  

<aui:input name="email" >
 <aui:validator name="required"/>
 <aui:validator name="alpha"/>
</aui:input>

<aui:button type="submit" name="" value="Submit"></aui:button>

</aui:form>


Step6:- put the jsp code as shown in the figure . the following is:-

view.jsp
add_student.jsp
display_search_student.jsp
display_student.jsp
search_by_name.jsp
student_details.jsp
update_by_id.jsp
update_student.jsp

Step7:- write the java code as below

package com.reg;

import java.io.IOException;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;

import com.liferay.counter.service.CounterLocalServiceUtil;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.util.ParamUtil;
import com.liferay.util.bridges.mvc.MVCPortlet;
import com.reg.model.Student;
import com.reg.service.StudentLocalServiceUtil;

/**
 * Portlet implementation class Regform
 */
public class Regform extends MVCPortlet {
public void addStudent(ActionRequest actionRequest,ActionResponse actionResponse) throws IOException,
PortletException, SystemException {

System.out.println("hello to this page");
long studentId;

studentId = CounterLocalServiceUtil.increment();

String firstName = ParamUtil.getString(actionRequest, "firstName");
System.out.println(firstName);
String lastName = ParamUtil.getString(actionRequest, "lastName");
String branch = ParamUtil.getString(actionRequest, "branch");
int age = (int) ParamUtil.getLong(actionRequest, "age");
String email=ParamUtil.getString(actionRequest, "email");
System.out.println(email+" yes");
Student student = null;
student = StudentLocalServiceUtil.createStudent(studentId);
student.setStudentId(studentId);
student.setFirstname(firstName);
student.setLastName(lastName);
student.setBranch(branch);
student.setAge(age);
student.setEmail(email);
StudentLocalServiceUtil.addStudent(student);

actionResponse.setRenderParameter("mvcPath",
"/html/regform/display_student.jsp");
}

public void updateStudent(ActionRequest actionRequest,
ActionResponse actionResponse) throws IOException, SystemException, PortalException {
System.out.println("yes it is progress");
long studentId=ParamUtil.getLong(actionRequest, "studentId");
String firstName = ParamUtil.getString(actionRequest, "firstName");
String lastName = ParamUtil.getString(actionRequest, "lastName");
String branch = ParamUtil.getString(actionRequest, "branch");
int age = ParamUtil.getInteger(actionRequest, "age");
String email=ParamUtil.getString(actionRequest, "email");
System.out.println("update");
Student student = StudentLocalServiceUtil.getStudent(studentId);
if (student != null) {
// fill update information
   student.setFirstname(firstName);
student.setLastName(lastName);
  
student.setBranch(branch);
student.setAge(age);
student.setEmail(email);
System.out.println("yes");
}
student = StudentLocalServiceUtil.updateStudent(student);
        actionResponse.setRenderParameter("mvcPath",
"/html/regform/display_student.jsp");
}
public void deleteStudent(ActionRequest actionRequest,
ActionResponse actionResponse) throws IOException,  PortalException, SystemException {

long studentId = ParamUtil.getLong(actionRequest, "studentId");
System.out.println(studentId);
Student student = StudentLocalServiceUtil.deleteStudent(studentId);
actionResponse.setRenderParameter("mvcPath",
"/html/regform/display_student.jsp");
}
public void getStudent(ActionRequest actionRequest,
ActionResponse actionResponse) throws IOException,PortalException, SystemException {
long studentId = ParamUtil.getLong(actionRequest, "studentId");
System.out.println(studentId);
String cmd = ParamUtil.getString(actionRequest, "cmd");
Student student = StudentLocalServiceUtil.getStudent(studentId);
actionResponse.setRenderParameter("mvcPath",
"/html/regform/update_student.jsp");
}
}

Explanation:- in this above code put every jsp ,java ,service.xml and check the path of jsp file as we are using render url if the path is not correct then it will not hit the other jsp file .
The two bottom in there home and back buttom , if we click on back then the particular page should be appeared so on that pupose we have to make a individual url of two jsp file so the back buttom will work. Examine the jsp code properly and you will see when you will click on search buttom then the form will display then by clicking on back button then search option will display perhaps when you click on display buttom then display page will display and by clicking on first name then form will display then after that when you click on back button then again the previous page will open ,before copy and deploy examine the code.








The following figure:-









































                           CRUD_Operations_inLiferay


                                       

                                                            
                                               hope this helps you...