Search This Blog

Tuesday, July 30, 2013

SAP Error Codes

The SAP native error codes during its integration with other technologies are always difficult to understand.. Here is a possible list of standard SAP Error Codes

/**********************************************************************/

/* Standard error codes.                                              */

/**********************************************************************/


ECodeECodeECodeECodeECodeECodeECodeECodeECodeECodeECodeECodeECodeECodeECodeECodeECodeECodeECode



Wednesday, July 24, 2013

Form re submission of/on Page Reload Errror

The property 'action-url-redirect' must be added to the liferay-portlet.xml file. This will not allow the form to be re submitted once the page is refreshed after a form submission is already done.




By default the property is false and thus the form resubmission occurs

Display error and success messages in liferay

Error Display Many times we need to display the errors messages or the success messages on the jsp pages.The way it is done is the following. Add the following the your implementation of processAction.
 //for Errors 
    com.liferay.portal.kernel.servlet.SessionErrors.add(portletRequest, "unique-error-key"); 
//for Messages 
    com.liferay.portal.kernel.servlet.SessionMessages.add(portletRequest, "unique-message-key"); 
or In Language_xx.properties add your custom message in this file like this
unique-message-key2="Success"

 TO display them in your jsp use this:

Friday, July 19, 2013

Running liferay script on control Panel Script console

Liferay has a script console at the Control Panel. It is accessible to the Liferay administrator. In the Script console Liferay API code , and other various code can be run seamlessly.

The script console is located at

ContolPanel --> Server --> Server Administration. 






 Here are few examples of codes run in the console and screenshot of the output. Most of the  codes were run here by selecting the Language as "Groovy".

Example 1.  Get list of users

Language : Groovy
code:

import com.liferay.portal.service.UserLocalServiceUtil;

userCount = UserLocalServiceUtil.getUsersCount();
users = UserLocalServiceUtil.getUsers(0, userCount);
count=0;
for (user in users) {
    count++;
    println(count+". User: " + user.getFullName());

}





































Example 2.  Get list of roles supported be the portal.


Language : Groovy
code:

import com.liferay.portal.service.RoleLocalServiceUtil;

roleCount =RoleLocalServiceUtil.getRolesCount();
roles=RoleLocalServiceUtil.getRoles(0,roleCount );

for(role in roles){
    println("Role Name: " + role.getName());
}




Example 3.  Get number of users in the portal . (using Javascript as language default script)
Language : Javascript
code:

number = Packages.com.liferay.portal.service.UserLocalServiceUtil.getUsersCount();

out.println(number);



How to Remove default Success Message your-request-completed-successfully



There are several ways to remove the message from displaying.


To remove the display use any of the following mentioned approach:

1. Remove entirely from a Portlet :
 Add this init param to your portlet.xml:


2. Remove  from specific  Portlet actions:
Add this to your implementation of processAction method.
SessionMessages.add(actionRequest, 
(LiferayPortletConfig)portletConfig.getPortletName()+ 
SessionMessages.KEY_SUFFIX_HIDE_DEFAULT_SUCCESS_MESSAGE);
  

3.Using Hook for HOOK for html\common\themes\ portlet_messages.jspf

a) remove the message display from all the portlets.



Comment out the lines , then the message will not be displayed for any of the portlets in Liferay at all.

b) remove the message display from specific portlets.

  create a hook and edit the portlet_messages.jspf file. Use the portletId to show/hide the message display. As shown

 

4. Masking with Custom Message in Portlet : Change that message key in your portlet's language.properties file with your custom text. Like, in the language_en.properties file for your custom portlet. add the custom message to the key:

 your-request-processed-successfully=Success! Process completed with no Errors. 

How to remove the message you-have-entered-invalid-data

There are several ways to remove the message from displaying. This message is present in the portal at the following path :-

   html\taglib\ui\error\end.jsp   


To remove the display use any of the following mentioned approach:

1. Using HOOK for all portlets :create a hook and edit the end.jsp file. In which you can comment out the lines , then the message will not be displayed for any of the portlets in  Liferay.

2. Using HOOK for specific portlet: create a hook and edit the end.jsp file. Use the portletId to show/hide the message display.


 


3. Masking with Custom Message in Portlet :
Change that message key in your portlet's language.properties file with your custom text.
Like, in the language_en.properties file for your custom portlet. add the custom message to the key:

   you-have-entered-invalid-data=Server Error: Please try again. 


4. Using CSS property:
Hook the file end.jsp (at html\taglib\ui\error\end.jsp ) with a surrounding CSS.


in the custom CSS of your portlet add

   .portlet-msg-error-invalid-data-show-hide{
     display : none;
   }

Wednesday, July 17, 2013

You are not allowed to use this program (crontab)

The crontab command used in unix sometimes shows the following error.

crontab -e
You (UnixUser) are not allowed to use this program (crontab)
See crontab(1) for more information
The system checks cron.allow file for allowing the user to use the crontab command. So, just add the user to the crontab.allow using the following command.
[UnixUser~]$ su
Password:
[root UnixUser]# echo UnixUser> /etc/cron.allow
 
Cron is driven by a crontab (cron table) file, a configuration file that specifies shell commands to run periodically on a given schedule.

XML Validation in Liferay

The property 'xml.validation.enabled' must be added to the Portal-ext.properties file.
If set false,

xml.validation.enabled=false

The xml files won't be validated inside the liferay. In some cases,where the xml,DTD ..etc files are kept external. This property can be used to avoid the validation errors.

Tuesday, July 16, 2013

Enable Transactional cache in Liferay

RSS Portlet Connection Timeout

The property 'rss.connection.timeout' must be added to the Portal-ext.properties file.
Set the timeout in milliseconds like,
rss.connection.timeout=2000
This makes the RSS reades wait untill 2 seconds for reading the RSS feeds before timeout.

Show / Hide Lookand Feel Icon on a Liferay portlet

The property 'portlet.css.enabled' must be added to the Portal-ext.properties file.

If made true,

portlet.css.enabled=true

# shows the 'Look and Feel' icon on the portlet titlebar. Enabling the user to edit it.This is default.

If made false,

portlet.css.enabled=false

# hides the 'Look and Feel' icon on the portlet titlebar . Disabling it can speed up the portal performance.

How to get the current logged in user in liferay

There are more than one way to do this. Let's look at some of the options available.
  1. User user = (User) request.getAttribute(WebKeys.USER);
    The User class is the Liferay's model User class.

  2. ThemeDisplay td  = (ThemeDisplay) request.getAttribute( WebKeys.THEME_DISPLAY );
    User user = td.getUser();


    This ' ThemeDisplay 'class can be used to get various information about the portal page,user and theme. Classes ThemeDisplay, User and WebKeys are available in portal-service.jar

  3. User currentUser = PortalUtil.getUser( request );

    The 'PortalUtil' has various utility functions , which come handy during Liferay Programming. This is also a part of the Portal-service.jar.

  4. LiferayFacesContext liferayFacesContext = LiferayFacesContext.getInstance();
    User currentUser=liferayFacesContext.getUser();


    The class 'PortalFacesContext' has been renamed to 'LiferayFacesContext'.This class exists in order to assist with migrating old JSF 1.2 based projects from the legacy PortletFaces-Tools project to the new LiferayFaces project.

    Hope It helps you in your portal programming. Happy Coding :)


My Blog List