Thursday, 18 June 2015

How to debug specific condition using Liferay Developer Studio

Many a times I have seen people strugle debugging a lenghty code unnecessarily. When you want to debug and check specific conditions then no need to iterate through each element while debug your code. You can put conditional check point and straigh away check your peace of functionality/condition.

There are two simple steps to do same.

1) Add conditional break point on the line where you like to break
2) Start server in debug mode and execute your functionality

Let's see both the steps in detailed.

1) Add conditional break point on the line where you like to break

i)    Inside Liferay developer studio add break point in your code
ii)   Right click on the break point and go for "Breakpoint properties"

iii)  New popup will be opened up tick mark "Conditional"

iv)  Inside content area write your specific condition
v)   Click on "Ok" button

2) Start server in debug mode and execute your functionality

Start your server in the debug mode. Refer blog "Start liferay tomcat in a debug mode"
(http://technoknowledgespread.blogspot.com/2014/09/start-tomcat-in-debug-mode.html)
If you are having a java stand alone project you can directly right click on the project and go for "Debug As" -> "Java Application"


Note: I have used the stand alone java application to demonstrate "conditional break point" feature of Liferay Developer Studio. You can use for web application as well. I have added break point for "IN" so in "console" output you can see that before "IN" all country code have been displayed and break point has directly stopped on the "IN" condition.

Cheers! You are done.

Cheers!
Henal Saraiya
(Senior Consultant)
CIGNEX Datamatics

No comments:

Post a Comment