Category Archives: Java

My First Android App

I was learning android native application development. I developed a sample application to detect the operator and circle of a given mobile number. This is an database application. You can follow the development at GitHub.

If you want to install it on you android mobile click here.

If you do not have android phone then do not worry I have an alternative for you. Click here to access the application from Internet.

XPage – Sort View Column

I was searching for a work around to allow view column to be sortable by clicking on column header but I was not able to find any reliable solution using View Panel. Now I found a way to provide this feature using Repeat Control or Data Table.

Please go through the following code.
var loView:NotesView = null;
var loEntryColl:NotesViewEntryCollection = null;
var loTreeMap:java.util.TreeMap = new java.util.TreeMap();
var lsSortBy = viewScope.get(“sortBy”);
try {
loView = database.getView(“view”);
if(null == lsSortBy || “” == lsSortBy) {
lsSortBy = 0;

if(null != loView && loView.getEntryCount() > 0) {
loEntryColl = loView.getAllEntries();
var loEntry:NotesViewEntry = loEntryColl.getFirstEntry();
var loTempEntry:NotesViewEntry = null;
while(null != loEntry) {
loDoc = loEntry.getDocument();
var lsKey = loEntry.getColumnValues().get(lsSortBy);

while(loTreeMap.containsKey(lsKey)) {
lsKey += “~”;

loTreeMap.put(lsKey, loEntry.getColumnValues());

loTempEntry = loEntryColl.getNextEntry(loEntry);
loEntry = loTempEntry;
} catch(e) {
print(“Error : ” + e);
} finally {
if(null != loView) loView.recycle();
if(null != loEntryColl) loEntryColl.recycle();

return loTreeMap.values();

In line 3 I am defining a TreeMap data structure. By definition TreeMap is sorted according to its natural ordering of its keys.

Since the data structure is always sorted so we can insert NotesViewEntry column values to the TreeMap and the corresponding column value (by which the view needs to be sorted) should be passed as key.

Look at line no 17 I am forming the key by which the view needs to be sorted. By default it is first column value.

At this point of time the only thing which creates problem is the duplicate values of the key. In TreeMap the value is overwritten if the key is already existing.

From line 18-21 I am appending additional character to make the key unique.

In line 37 I am returning value set from the TreeMap which is already sorted by key.

Rest of the code is quite easy to understand. I hope it may help in your application.

Optimization of the above code is discussed in next blog.

Debug Java From Lotus Notes Designer

We do not prefer to write agents in Java just because we are not able to debug the Java agent in Lotus Notes Designer. As we think Designer do not have any debugger for Java, but let me clarify that Lotus Notes Designer 8.5.x (also known as Domino Designer in Eclipse) has in-built Java debugger.

It is very clear that to write a Java agent we must extend AgentBase class and implement notesmain() function. So if our Java agent requires Domino Infrastructure to execute then how can we debug it? We have to make it a Java application to debug it. So we must define main function in our Java agent.

I am assuming the name of the agent class is MyAgent.

protected Session _goSession;
protected AgentContext _goCtx;

public MyAgent(){}

public MyAgent(Session s, AgentContext c) {
_goSession = s;
_goCtx = c;

public static void main(String[] args) {
Session s = null;


try {
s = NotesFactory.createSession();
// NotesMain(), the way Domino does
MyAgent a = new MyAgent(s, s.getAgentContext());

} catch (Exception e) {
} finally {
try {
if (s != null) s.recycle();
} catch (Exception x) {}
} // end main


After adding above code to your Java agent switch to Java Debugger Perspective and goto Debug Configuration and double click on Java Application in left side. Check stop in main option and click on debug button to start debugging.

I hope this helps you in debugging your Java agent. If any query feel free to write me back…:)

Lets Start Java

From last few days I was struggling with Eclipse and Tomcat. I was not able to execute servlet from Eclipse IDE. After doing a lot of research finally I got the solution. All I need to do is to copy a folder “tomcat/webapps/ROOT” to “workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps” (or …/tmp1/wtwebapps if you already configured another server).