Pages

Sunday 8 March 2015

SaaS (Software as a service) with Liferay


 Yes, you are surprising na... why I have included SaaS over here, Its there from the first release of liferay. I am just trying too map some facts by which you can design  your liferay implementation on Saas standards.

I will not explain what is SaaS & its features you can read it from wiki.


As you know liferay is horizontal portal i.e 


Specialized website (portal) that serves as an entry point to several firms in the same industry or to the same type of suppliers. See also vertical portal.

80% of portal used to implement to fullfil the above ask ahh?

So why not make it deliverable to end user in such a way that we can sell it on subscription basis. 

With the help of example it will be easier to understand and then implement in actual real life portal.


Inkwell company got an order to deliver POS(point of sell) for a medical outlet "M.M medical store".

Now some good Architect decided to deliver it in Liferay. Since blank fresh Liferay was already there on cloud. So it will save lots of installation & setup work.

One of the solution architect decided to hire a experinced developer of POS. He can develop a POS in 20 days with using traditional spring hibernate code.

Now take his code & convert his project to Liferay portlet.

That's its


Development has ended with this. Now we will have to play with liferay configurations.

In default liferay instance create an site(organization) named as "M M medical store" on its private page deploy the war which you have developed from liferay IDE.

create a site administrator user for MM site.

Benefits & Execution of SaaS after first client 


1. You can restrict no. of user in MM site.
2. you can schedule the expire of MM site after a fixed interval of time as per subscription plan.
3. you can create new site if new client comes for same requirement.
4. you can give different look & feel for different site.
5. With single server you can server N no. of  client,
6. No need to develop and deploy code again
7. each client can get updated & bug fixes code by default.
8. Only one super administrator can control whole single type of domain.
9. you can give option to client pay as you grow.
10. you can show zero processing fess & installation in seconds to client/
.

and many more.




Keep sharing, what you learn... :)

Tuesday 13 January 2015

GenericPortlet in Liferay


As per JSR286 , Portlet Specification 2.0 we can create portlet on above of liferay that follow standard as per specification so that in near future when we want to switch Liferay portal with any other portal server like Jboss we need not to change code.



Monday 29 September 2014

Disable Built-in portlet (Default) in Liferay

Hi Friends,

As we know liferay comes with bundle of 60+ App(portlet) built in with default installation.
 Like

  • Asset Publisher
  • Blog
  • Blog Display
  • Navigation
  • Tag
  • Breadcrumb
WE can use them as per requirement.
Still many of portlet are not useful when we designing for real application. Therefore It is recommended that we have to disable them so that these portlet will not appear in App section as well as control panel.

When we disable any portlet JVM does not load the classes related to that particular portlet so we can also optimized the Liferay portal by disabling the unused portlet.

To disable a built-in portlet we have two options.

Using lifeary-portlet.xml


1. Directly modified the liferay-portlet.xml file located at following path

<liferay installation><tomcat-7.0.42 or your app server>\webapps\ROOT\WEB-INF\

2. find the portlet with id if you know or by name as well
for example I want to disable the liferay search portlet then we know its id is 2

3. you will get a block like this



<portlet>
<portlet-name>2</portlet-name>
<icon>/html/icons/my_account.png</icon>
<struts-path>my_account</struts-path>
<portlet-url-class>com.liferay.portal.struts.StrutsActionPortletURL</portlet-url-class>
<control-panel-entry-category>my</control-panel-entry-category>
<control-panel-entry-weight>1.0</control-panel-entry-weight>
<preferences-owned-by-group>true</preferences-owned-by-group>
<use-default-template>false</use-default-template>
<private-request-attributes>false</private-request-attributes>
<private-session-attributes>false</private-session-attributes>
<render-weight>50</render-weight>
<header-portlet-css>/html/portlet/users_admin/css/main.css</header-portlet-css>
<footer-portlet-javascript>/html/portlet/users_admin/js/main.js</footer-portlet-javascript>
<css-class-wrapper>portlet-users-admin</css-class-wrapper>
<add-default-resource>true</add-default-resource>
<system>true</system>

</portlet>

4. now at the end of this block just before closing of portlet tag </portlet> put the following line,

<include>false</include>

and the above code will look like this after changes.



<portlet>
<portlet-name>2</portlet-name>
<icon>/html/icons/my_account.png</icon>
<struts-path>my_account</struts-path>
<portlet-url-class>com.liferay.portal.struts.StrutsActionPortletURL</portlet-url-class>
<control-panel-entry-category>my</control-panel-entry-category>
<control-panel-entry-weight>1.0</control-panel-entry-weight>
<preferences-owned-by-group>true</preferences-owned-by-group>
<use-default-template>false</use-default-template>
<private-request-attributes>false</private-request-attributes>
<private-session-attributes>false</private-session-attributes>
<render-weight>50</render-weight>
<header-portlet-css>/html/portlet/users_admin/css/main.css</header-portlet-css>
<footer-portlet-javascript>/html/portlet/users_admin/js/main.js</footer-portlet-javascript>
<css-class-wrapper>portlet-users-admin</css-class-wrapper>
<add-default-resource>true</add-default-resource>
<system>true</system>
               <include>false</include>

</portlet>



5. save the file & restart the server just it.

Using lifeary-portlet-ext.xml


1. create a ext plugin project.

go to
docroot/WEB-INF/ext-web/docroot/WEB-INF/

2.
open liferay-portlet.xml file



& place the below code before closing  </liferay-portlet-app>

<portlet>
<portlet-name>2</portlet-name>
<icon>/html/icons/my_account.png</icon>
<struts-path>my_account</struts-path>
<portlet-url-class>com.liferay.portal.struts.StrutsActionPortletURL</portlet-url-class>
<control-panel-entry-category>my</control-panel-entry-category>
<control-panel-entry-weight>1.0</control-panel-entry-weight>
<preferences-owned-by-group>true</preferences-owned-by-group>
<use-default-template>false</use-default-template>
<private-request-attributes>false</private-request-attributes>
<private-session-attributes>false</private-session-attributes>
<render-weight>50</render-weight>
<header-portlet-css>/html/portlet/users_admin/css/main.css</header-portlet-css>
<footer-portlet-javascript>/html/portlet/users_admin/js/main.js</footer-portlet-javascript>
<css-class-wrapper>portlet-users-admin</css-class-wrapper>
<add-default-resource>true</add-default-resource>
<system>true</system>
               <include>false</include>

</portlet>

3.
Deploy the war in deploy folder of your app server.

4. since its a ext plugin so you will have to restart the server after deployment.



Please let me know if you have any query. 


Keep sharing, what you learn... :)





Tuesday 15 July 2014

Run PHP application inside Liferay server

yes, as all we know Liferay supports almost all scripting language like ruby & PHP.
To run PHP application we will have to follow these steps.

1. Try to make a dummy PHP initially. So that in first integration testing it will easy to debug.

2. Create a new txt file with below content.

<?php
$first_number = 10;
$second_number = 20;
$sum_total = $first_number + $second_number;
$direct_text = 'The two variables added together = ';
print ($direct_text . $sum_total);
?>


save the file from .txt to .php extension.


3. now right click on this file & zip that file say myphp.zip

4. Like all .war file you just have to but this zip file inside deploy folder of liferay server.

5. Either it will taken care by hot deploy or you can restart the server.

6. Now login into liferay with admin role.

7. Goto add bottom a list of available portlet will appear.

8. You will see myphp drag & drop this to your page that it.

9. Your PHP portlet now in action.

The two variables added together = 30


Keep Sharing...
                   what you learn.......



Problem in Liferay 6.2 CE Installation




I have noticed that Liferay 6.2 CE standard version doesn't come with JRE inside tomcat.
So when you try to start the liferay server on windows the terminal will close by its own.
& in linux you will get JRE not found like error.

The main cause of this is that we dont have jre inside Tomcat bundle in liferay.


  • To resolve the same issue either download a fresh bundle with JRE included.

download from here

  • Or you can copy & paste JRE folder inside your liferay 6.2 tomcat from the last liferay 6.1 version. 


Please let me know if you have any query. 


Keep sharing, what you learn... :)




Friday 23 May 2014

portal.properties: Load properties from external file

Hi,
        This topic is simple but mandatory for developer to go through with it since this comes with best practices.


1. Include "com.liferay.util.portlet.PortletProps" package into your jsp or in java


2. Make a properties file & put into source folder of your portlet named as portal.properties.


3. put some entries in that file like
                 my_custom_message=this is from your external properties files

4. Now you can fetch the properties by the following way:


  • In Jsp

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
               <portlet:defineObjects />
               <%@ page import="com.liferay.util.portlet.PortletProps" %>
               <%= PortletProps.get("messages.per.page") %>

                



  • In  Java
import com.liferay.mail.util.PortletProps;

PortletProps.get("messages.per.page");



Wednesday 14 May 2014

Display profile pictures of all users in liferay?

Hi,

 Today I am going to show you how you can get Profile picture or Portrait of all users belonging to particular community or organization. Yet the problem sounds little bit easy but this post will save your time to make it correct in single attempt.


Problem :  I want to show a  slider to end user in which logo of all my clients will comes. It will look nice since it is dynamically generated means whenever a user will register & admin has assigned Client(Vendor) role to that particular  user.

Than his/her profile pic or in case of company a logo will automatically append in the existing slider....

Solution:

 1.  Make a simple portlet.

 2.  Put the following code in to your view.jsp


<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ page import="com.liferay.portal.service.UserLocalServiceUtil"%>
<%@ page import="com.liferay.portal.model.User"%><%@ page import="java.util.List"%><portlet:defineObjects /><h1> Our Partners</h1><marquee behavior="scroll" direction="left"><%int i= UserLocalServiceUtil.getUsersCount();List<User> user =UserLocalServiceUtil.getUsers(0, i);String imgsrc="/image/user_male_portrait?img_id=";for(int j=1;j<i;j++){%><img src="<%=imgsrc+user.get(j).getPortraitId() %>"/>&#160; &#160; &#160; &#160;<%} %></marquee>


3. Deploy this portlet on liferay server.

4. Put ity on desire page.

5. It will show a slider(marquee) with profile pic of all users.6. Here is the output









Please keep sharing.... what you learn.


:)