Posts

Showing posts from August, 2012

SmartGWT Calendar widget scroll to Current Time in month view

The calendar widget of smartgwt is quite powerful. But it lacks one important functionality, that is, scroll to the current time in case of month view. But this feature can easily be enabled by working on the Workday feature which smartGWT calendar widget supports. I wrote a simple function to achieve the same: private void scrollToCurrentTime() { int[] workDays = new int[1]; Date now = new Date(); workDays[0] = now.getDay(); int currentHour = now.getHours(); now.setHours(currentHour-1); String start = DateTimeFormat.getFormat( PredefinedFormat.TIME_SHORT).format(now); now.setHours(currentHour+7); String end = DateTimeFormat.getFormat( PredefinedFormat.TIME_SHORT).format(now); calendar.setWorkdays(workDays); calendar.setWorkdayStart(start); calendar.setWorkdayEnd(end); calendar.setScrollToWorkday(true); calendar.setShowWorkday(true); }

Correct way to use SNMP4J in concurrent environment.

SNMP4J is one of the most popular Java library for SNMP (Simple Network Management Protocol) operartions. Its quite powerful and easy to use. But it seriously lacks a good documentation.  In my project at work, which is a concurrent environment, I faced a funny problem. I was using a simple snmp trap listener code as shared in the java docs and in numerous amount of blogs. But, the listener use to stop working after a while. Little more debugging and I figured out that it use to stop working only after somewhere else in the code someone has used the same library for SNMP get operation. Then, i went ahead googling to see if anyone else has ever faced a similar problem. But in vain! Checked the bug list on SNMP4J to see if any such similar issue exists. No luck again! Then I decided to understant the scenario properly and started reading the SNMP4J java source code and Bazinga!! The very basic source code share with the documentation gives us a wrong implementation of the trap li