Tuesday, January 02, 2007

PopCalendarXP and Struts

Being a java developer, one might have to work on the web development. And when we talk about Web Development, we think about user interface, user input, form, dates and when we talk about dates, JavaScript Date Picker comes into play.

We all use JavaScript date picker in our web development and there are lots of javascript date picker available on the net. We just need to google it.

My recent project required to have date picker which should have pre-populated dates highlighted when user click on the Date Picker. Well there might be bunch of such java script available but what I found out was PopCalendarXP. When I looked at their homepage I found out that this is the one I wanted. So I started looking at their Tutorials, Demos and I found it very helpful.

One of the feature of PopCalendarXP is you can define your own events, holidays which will be highlighted into your date picker. Here is the link for Demos and Tutorials

One way to add events into your PopCalendar was “Retrieving agenda events from backend data source”. I was reading through that tutorial found out that they were showing the legacy system where your JSP file is being called directly from server. But thats very rare now. Very few applications might be using this way now. Most of the applications now uses Sturts or some sort of controller framework. My project is also using Struts. Also instead of using the fLoadScript() function that they defined, I used AJAX fLoadEvents() function. This is AJAX era and If I dont use it, i would feel left out. ;-).

So I changed my code a little as following.

instead of following..

var url = "/jsp/agenda.jsp?year="+y+"&month="+m;

I used

var url = "/myAjaxAction.do?action=getAjaxThingie&year="+y+"&month="+m;

The Actual work was done in Struts. In My Action Class which is mapped to myAjaxAction.do, I have something like this.


So make sure you return null as we dont want struts to forward this call to anywhere. We just need Response and write it back to our JavaScript. I hope this article helped you. Please write me back if you have any questions regarding this particular topic. I think I can help.

No comments: