Monthly Archives: January 2012

Rashid’s Facebook Like Box Plugin for WordPress

I was searching for a plugin to add Facebook Like Box on my blog but I did not found any suitable plugin which suits my purpose. I found few plugins at WordPress.org but they don’t support my wordpress version. So I decided to write my own plugin. You can also download it and use it at your wordpress blog as well. Click here to download the plugin.

Installation:

Download the plugin.

Upload to your blog (/wp-content/plugins/).

Activate it.

Click the RA-FB Like Box.

Fill in the options.

Then go to widget and drag and drop Rashid’s Facebook Like Box in the area you want to display the plugin.

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.
[javascript]
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.recycle();
loEntry = loTempEntry;
}
}
} catch(e) {
print(“Error : ” + e);
} finally {
if(null != loView) loView.recycle();
if(null != loEntryColl) loEntryColl.recycle();
}

return loTreeMap.values();
[/javascript]

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.