Search This Blog

Monday, January 18, 2016

Remove Default Error Message in Liferay

Liferay displays a partuculat error message on each Login , e.t.c error. It reads out like this 

"You have entered invalid data, Please try again"

although we do not need this message everytime, as it is displayed on top of another error message like 

"Authentication failed. Please try again. "

So, if we need to remove the error message from the portal . We can do the following. 

Case 1: When we need to remove it entirely from the portal 

        solution : customize the "end.jsp" of "ui- error taglib"
                                     
       
       
       
       
       
       <%= rowBreak %>

Case 2: When we need to remove it only for a particular portlet.
          
        solution : customize the "end.jsp" with a condition of "ui- error taglib"

   
       
       
       if(strPortletId.equals("portlet_WAR_name")
       {
       // add your custom code here .
       }
       else
       <%{%> 
            
              
              
        
       <%}%> 
       <%= rowBreak %>
 
Other Solutions :-
 
  1. In Portlet .xml , 
 
         
            add-process-action-success-action
            false
         


 2. In java class, overrride the action method

         protected void addSuccessMessage(
         ActionRequest actionRequest, ActionResponse actionResponse) {
 
         if (!addProcessActionSuccessMessage) {
             return;
         }
          String successMessage = ParamUtil.getString(actionRequest, "successMessage");
          SessionMessages.add(actionRequest, "request_processed", successMessage);
          }









Monday, April 27, 2015

JAVASCRIPT/ JQuery Page Redirection

 

JAVASCRIPT/ JQuery Page Redirection

 

1. window.location.href="http://www.yahoo.com";

2. window.history.back(-1);                                     //  back

3. window.navigate("top.jsp");                                  // old-IE-only

4. self.location="top.htm";

5. top.location="error.jsp";

6. window.location = window.location.host;

7. $(location).attr('href',"http://www.yahoo.com");            //jQuery

8. $(window).attr("location","http://www.yahoo.com");        //jQuery

9. window.location.replace("http://www.yahoo.com");

10. window.location.assign("http://www.yahoo.org");

11. document.location.href = '/path';

12. window.history.go(-1);                                     //  back

13. $(location).prop('href',"http://www.yahoo.com");          //  jquery 

14.setTimeout(function(){
              window.location.href="<%=url%>"; // redirect after 5 seconds
   }, 5000);
 

Friday, November 8, 2013

Configure Cron Job for Schedulers


Cron

"Cron" is a UNIX tool which works as time-based job scheduler . The cron jobs can be configured by writing cron expressions which , the scheduler can understand. In this article we will show sample examples of cron expressions to understand it's configuration. 'CronTrigger' class uses the scheduling capabilities of cron to trigger the scheduler functions.

The Cron Expression

The cron expressions are  strings of texts made up of six or seven values separated by white space. The values are actually field positions which refer to a particular unit of time. The values are restricted to a specific syntax and numbers along with some special characters.

Position/TimeUnit Required Restricted Values  Restricted Special Characters
  1  Seconds    Yes        0-59           , - * /
  2  Minutes    Yes        0-59           , - * /
  3  Hours    Yes        0-23           , - * /
  4  Day of month    Yes        1-31           , - * ? / L W
  5  Month    Yes    1-12 or JAN-DEC           , - * /
  6  Day of week    Yes    1-7 or SUN-SAT           , - * ? / L #
  7  Year    No    empty, 1970-2099           , - * /


  • '*' (all values):-wildcard used to mean all values in possible in the time unit.

  • '?' (any specific value, only for day-of-month and day-of-week ):- like * but limited to the mentioned fields only
  • '-'  (ranges of values):- like 1-2 would mean 1-2 units of time.
  • ',' (separated specific values):- 1,5 would mean cron will run only on 1st and 5th unit of time.
  • '/' (incremental value):- "0/10" would mean cron will run only on every 10th unit of time.
  • 'L' (last unit of time) :- "L in Day of month" would mean cron will run only on the Last day of the month. Similarly last day of year, week.. etc .
  • 'W' (nearest weekday) :- "10W" at the day-of-month field, would mean : "the nearest weekday to the 10th of the month"..
 note:- 'LW' at day-of-month field would mean last weekday of the month.
  • '#'(specific day of month) -  "1#2" in the day-of-week field would mean : "the second Monday of the month".(i.e.daynumber#occurance in the month)

The Cron Expression Examples
 
Cron Expression Time Meaning
0 0  13 * * ? Run at 13pm daily.
0 20 9 ? * * Run at 9:20am daily.
0 25 9 * * ? Run at 9:25am daily.
0 25 6 * * ? * Run at 6:25am daily.
0 5 11 * * ? 2013 Run at 11:5am daily, throughout the year 2013
0 * 15 * * ? Run every minute, starting at 3pm and ending at 3:59pm, daily.
0 0/10 17 * * ? Run every 10 minutes starting at 5pm and ending at 5:55pm, daily.
0 0/10 17,18 * * ? Run every 10 minutes starting at 5pm and ending at 5:55pm, AND Run every 10 minutes starting at 6pm and ending at 6:55pm, daily.
0 0-10 10 * * ? Run every 1 minute starting at 10am and ending in 10 minutes, daily.
0 10,20 10 ? 4 Fri Run at 10:10am and at 10:20am every Friday in the month of April.
0 25 20 ? * MON-FRI Run at 8:25pm every weekday.
0 20 9 10 * ? Run at 9:20am on the 10th day of every month
0 20 9 L * ? Run at 9:20am on the last day of every month
0 20 9 L-3 * ? Run at 9:20am on the 3rd-to-last last day of every month
0 20 9 ? * 6L Run at 9:20am on the last Friday of every month
0 20 9 ? * 6L Run at 9:20am on the last Friday of every month
0 20 9 ? * 6L 2002-2005 Run at 9:20am on every last friday of every month during the years 2002, 2003, 2004 and 2005
0 20 9 ? * 6#3 Run at 9:20am on the third Friday of every month
0 0 13 1/15 * ? Run at 13pm every 15 days every month, starting on the first day of the month.
0 12 12 12 12 ? Run every December 12th at 12:12am.


Happy coding :)

How to select DISTINCT on a CLOB field.

Lets consider a table 'PREFERENCES' with two values 'ID' and 'PREFERENCES'. Where id is a Number and preferences is a CLOB field.

      ID   PREFERENCES
---------- ---------------------------------------------
         1 Oracle 
         2 Oracle 
         6 MSSQL
         7 MySQL
         8 Oracle

 


Now  if you want to find out how many distinct values are there in the Preference column.You might try to use;



This will generate the following  SQL error:



If you then use



This will also generate error :-


as per the Error Description If you use



Still, an SQL Error will be thrown , which is

There are lot of ways to solve this problem.One of the simplest way is to increase the Buffer in the same sql . As displayed below.



This runs without error and gets you all the unique values of preferences column.

Happy Coding!!




Friday, October 18, 2013

To make JSP compatible with IE8 or IE 9

Add the following code to the javascript block.

#if ($browserSniffer.getMajorVersion($request) < 9)
  <meta http-equiv="X-UA-Compatible" content="IE=8" />
#else
  <meta http-equiv="X-UA-Compatible" content="IE=9" />
#end

this will make the jsp compatible with IE 8 or IE 9

Happy Coding !!

 

My Blog List