Posts

Showing posts from June, 2015

Liferay Tabs Search container pagination

question_list.jsp  String tabNames = "Active Questions,InActive Questions"; String tabs1= ParamUtil.getString(request,"tabs1", "Active Questions");     Object ob = request.getAttribute("selectedTab");     String value ="Active Questions";     if (ob != null) {     value = (String) ob;     tabs1 = value;     } PortletURL iteratorURL = renderResponse.createRenderURL(); iteratorURL.setParameter("action", "questionlist"); <liferay-ui:tabs    names="<%= tabNames %>"    url="<%= iteratorURL.toString() %>"      param="tabs1"    value="<%=tabs1 %>"   >     <liferay-ui:section>      <c:if test='<%= tabs1.equalsIgnoreCase("Active Questions")%>'>       <liferay-ui:search-container delta="10" emptyResultsMessage="Sorry" iteratorURL="<%= iteratorURL %>">       .........       ..

Date pickers

AUI Date Picker: To Use AUI we need to import: <%@ taglib uri="http://alloy.liferay.com/tld/aui" prefix="aui"%> Then add your input field: <aui:input type="text" name="datepicker" id="datepicker" /> Then add this script: <aui:script> AUI().use('aui-datepicker', function(A) { new A.DatePicker({ trigger : '#<portlet:namespace/>datepicker', popover : { zIndex : 1 } }); }); </aui:script> Liferay UI DatePicker: We need to import: <%@taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %> Then add your input field: <liferay-ui:input-date formName="dob" yearRangeEnd="2000" yearRangeStart="1950" yearValue="1990" monthValue="3" dayValue="20" dayParam="d1" monthParam="m1" yearParam="y1"/> Jquery DatePicker: To Use Jquery Date Pi

Currency symbol for all countries

Code to get currency symbol:     Currency currency = null;     Locale locale = null;     String currencySymbol = null;   /*Get List of available countries from liferay country table*/     List<Country> countryCode = CountryServiceUtil.getCountries();         for(Country country:countryCode)     {         try{             locale = new Locale.Builder().setRegion(country.getA2()).build();             currency = Currency.getInstance(locale);                   currencySymbol = currency.getSymbol(locale);               System.out.println("currency symbol is......"+currencySymbol);             }         catch(Exception e){             System.out.println("exception..."+e);         }     }

Custom Landing Page Using hook Based On Role

Step 1: Define portal.properties in WEB-INF/liferay-hook.xml. <hook>     <portal-properties>portal.properties</portal-properties> </hook>  Step 2: Go to WEB-INF/src/portal.properties and define the following .  login.events.post=CustomLandingPage Step 3: Go to WEB-INF/src and create new class "CustomLandingPage.java" public class CustomLandingPage extends Action {     @Override     public void run(HttpServletRequest request, HttpServletResponse response) {         try {             String roleName =null;             User users= PortalUtil.getUser(request);             long []roleIds = users.getRoleIds();             LastPath publiclastPath= null;             for(long i:roleIds){                 Role role = RoleLocalServiceUtil.getRole(i);                 roleName = role.getName();                                 if(roleName.equalsIgnoreCase("Role name")){                      publiclastPath = new LastPath(StringPool.BLANK