Archive

Posts Tagged ‘Java’

Simple Calendar Control for Web Application

March 19th, 2010 Eric Silva No comments

I originally did this back in 2007, but did not want to lose the content, so I decided to put it up here.

I found a robust and relatively simple calendar control to use for web UIs. It can use a pop-up window or a floating <div> tag. I prefer the latter as it makes the page look good and avoids a pop-up.

To use the control simply put the CalendarPopup.js file in your application’s “scripts” directory and be sure to include it in your JSP. (I used this in a Java app, but you can apply it to any language.)

Download the and put it in your images directory.

Add the following lines to your application’s JavaScript file (or include on the same page if you don’t have an external JS file):

// Set up Calendar control
var calObj = new CalendarPopup("calDiv");
calObj.showNavigationDropdowns();
calObj.setMonthNames('JAN','FEB','MAR','APR','MAY','JUN','JUL','AUG','SEP','OCT','NOV','DEC');

// Handle the Calendar control
function doCalendar(destObjId, srcObj) {
    calObj.select(document.getElementById(destObjId),srcObj.id,'dd-MMM-yyyy');
}

Then add the following lines to your JSP:

<script>document.write(getCalendarStyles());</script>

In your JSP, add the following HTML code where you want your date field and calendar control:

<input id="dateField" style="width: auto;" maxlength="11" name="actualDate" size="25" type="text" />
<img id="imgCal" onclick="doCalendar('dateField',this);return false;" src="cal.gif" border="0" alt="" />

That’s it!

In order to workaround IE 6′s inability to recognize the z-index attribute on the tag, I made some modifications to the original JavaScript code. You will need to pass the an ID value to be used for the hidden that will overlay the box.

var calObj = new CalendarPopup("calDiv", "calFrame");

You will also need to specify the following styles in a stylesheet. The ID values in the stylesheet must match the names of your DIV and IFRAME IDs on your page.

div#calDiv {
    position:absolute; visibility:hidden;
    background-color:white;
    layer-background-color:white;
}
.select-free {
    position:absolute; z-index:10;/*any value*/
    overflow:hidden;/*must have*/
    width:152px;/*do not change value for calendar control */;
}
.select-free iframe#calFrame {
    display:none;/*sorry for IE5*/
    display:block;/*sorry for IE5*/
    position:absolute;/*must have*/
    top:0;/*must have*/
    left:0;/*must have*/
    z-index:-1;/*must have*/
    filter:mask();/*must have*/
    width:3000px;/*must have for any big value*/
    height:3000px/*must have for any big value*/;
}

Your JSP now needs the following line:

<div id="calDiv" class="select-free"></div>

GWT 2.0 Released!

December 9th, 2009 Eric Silva No comments

I just saw on my RSS that GWT 2.0 has been released.  Gonna go play now. Bye.

Can’t Find Shit on Oracle’s Website

October 21st, 2009 Eric Silva 1 comment

When Oracle first announced that they were acquiring BEA, the first thought that went through my head wasn’t “I wonder if Oracle AS will be dropped in favor of WebLogic.”; it was “Oh great! Now I won’t be able to find shit on the WebLogic forums too.”

It’s been several months since the acquisition, but today I got fed up.  BEA used to have a website, dev2dev.bea.com, where they would post clever tips, tricks, etc. about the WebLogic platform.  I would have thought that Oracle would have kept all of this “useful” content alive after the website consolidation, but I was wrong.  It wasn’t bad enough they killed the forums at BEA, which has since caused all Google searches to come up with a plethora of dead links since the BEA URLs no longer exist.  Links from other forums to BEA listings are now worthless as well.

But hey, I can always go over to the forums at Oracle’s website and search there right?  One would think that was a logical solution, that is until they found out the honest truth:  Oracle’s search engine is powered by the Total Perspective Vortex.  At least that is what it feel’s like each time I attempt to find any God-damned thing on their site.

All I wanted was the article about the Thread Dump Analyser (TDan) tool that was written a while back.  It’s the best tool out there IMHO for performing thread dump analysis and being able to represent the output in a visual way.  It’s a good thing I keep a backup copy of the tool available.

Good Night.