Featured post

Docker setup for Liferay 7 with MySQL

Showing posts with label liferay. Show all posts
Showing posts with label liferay. Show all posts

Friday, 7 September 2012

Be careful when you assign user management role to any user

Liferay has very fine grained permission system. But some of the issues require much attention from administrator side.

There is a threat i want to let you know that if you assign any user a role of User Management,
that means He/She has all the rights to change all the users information including Administrator.

So, be careful while you assign this kind of permission to any user.

You are just done, Try & Enjoy the function.............:))

Tuesday, 14 February 2012

Add Hidden/Admin portlets in Add more Applications Menu (Liferay)

Most of the requirement from the client comes by saying that they want the same user portlet as available in Control Panel. This can be achieved by below details.

1) Create a hook name addUserToAddApplication.
2) Create structure WEB-INF/jsp/html/portlet/layout_configuration.
3) copy view_category.jsp from source html/portlet/layout_configuration.
4) Add below lines in your jsp on line no 53 just above the while loop -

//   Use your own Category.

if(Validator.equals(portletCategory.getName(),"CATEGORY.NAME"))
{
     // 125 is portlet id of ENTERPRISE_ADMIN_USER PORTLET.

Portlet userportlet = PortletLocalServiceUtil.getPortletById(user.getCompanyId(), "125");
portlets.add(userportlet);
}

5) Deploy your hook.
6) Check your Add Application menu, you are free to add user portlet to your page.

Try & Enjoy the function....:))

Thursday, 26 January 2012

Column base sorting in Liferay's Search Container with BeanComparator.


Sometimes we have such requirement that we need sorting on our column basis,
   like by clicking on column it gives us sorted data in ascending/descending form.
You can define which column you want to sort and by which order.

By using BeanComparator, it gives you  flexibility not to create your own comparators.

1) Declare String variables to define order by column and order by type

String orderByCol = ParamUtil.getString(request, "orderByCol");
String orderByType = ParamUtil.getString(request, "orderByType");
if(orderByCol==null || orderByCol.equals(StringPool.BLANK)) {
request.setAttribute("orderByCol",orderByCol);
}
if(orderByType==null || orderByType.equals(StringPool.BLANK)) {
orderByType="asc";            //Default value for order by type
request.setAttribute("orderByType",orderByType);
}

// In your liferay Search Container pass this param orderByCol and orderByType

<liferay-ui:search-container  orderByCol="<%=orderByCol %>" orderByType="<%=orderByType %>" delta="10">

2) BeanComparator beanComparator=new BeanComparator(orderByCol);

if(orderByType.equals("desc"))
{
Collections.sort(list_Details,Collections.reverseOrder(beanComparator));
orderByType="asc";
}
else
{
Collections.sort(list_Details);
orderByType="desc";
}

//You have to make a copy of this list, otherwise it will throw an exception.

List<Test> copy_List_Details = list_Details;

// Assign it to results object of Search Container

results = ListUtil.subList(list_Details, searchContainer.getStart(), searchContainer.getEnd());

3)
                  //In your column's of Search Container make orderable true and pass orderableProperty,
                  //you can sort by as many colums as you want.


     <liferay-ui:search-container-column-text
     name="Start Date"
       value="<%=sDate_dis %>"
       orderable="<%=true %>"
         orderableProperty="regiStartDate"
     />


You are done with sorting, Try and Enjoy ....:))

Thursday, 3 November 2011

Create your own custom tld in Liferay at Portal Level.


If you are here that means you already know what is a TLD(Top Level Definition).
To include a TLD in Liferay at root level or you can say a portal level tld, you can follow the steps which will help you to create one on your own.

1. Create a hook name mytld.
2. Create mytld.jsp at /docroot/web-inf/jsps/html/taglib/ui/mytld/mytld.jsp.
3. Create an ext named mytld ext.
4. Move to web.xml by /docroot/web-inf/ext-web/docroot/web-inf/web.xml in ext.
5. Put below lines in web.xml.



<?xml version="1.0"?>

<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<jsp-config>
<taglib>
<taglib-uri>http://liferay.com/tld/ui-ext</taglib-uri>
<taglib-location>/WEB-INF/tld/liferay-fc.tld</taglib-location>
</taglib>
</jsp-config>

</web-app>



6. Create a corresponding java class for ur taglib(if required) at /docroot/web-inf/ext-util-taglib/src/com/liferay/taglib/ui/MyTld.java in ext.
7. Write required code.
8. Move to /docroot/web-inf/ext-web/docroot/web-inf/tld/liferay-fc.tld.
9. Put below lines in liferay-fc.tld.


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

<taglib>
    <tlib-version>1.0</tlib-version>
    <jsp-version>1.1</jsp-version>
    <short-name>my-tld</short-name>
    <uri>http://liferay.com/tld/my-tld</uri>
    <tag>
            <name>foodcourt-discussion</name>
            <tag-class>com.liferay.taglib.ui.FoodCourtDiscussionTag</tag-class>
            <body-content>JSP</body-content>
            <attribute>
                <name>attribute-name1</name>
                <required>true</required>
                <rtexprvalue>true</rtexprvalue>
            </attribute>
            <attribute>
                <name>attribute-name2</name>
                <required>true</required>
                <rtexprvalue>true</rtexprvalue>
            </attribute>
    </tag>
</taglib>


10. Deploy your ext.
11.Deploy your hook.
12.Restart your server.
12.Your new tld is ready to use.


Please let me know, if there is any concern about this Blog.