views:

35

answers:

1

I have existing javascript in a project that creates a 'Calendar' object. The object is a member of window.

When I added smartgwt to my project, the original Calendar object was overwritten by a smartclient calendar (ISC_Calendar) packaged in smartgwt.

Using a browser-based JS debugger, I found that all the JS objects from smartgwt were contained both in window and in window.isc. I definitely don't want them all at window level because many of them have generic names like Calendar.

The offending file in my case is ISC_Calendar.js, which ends up in war/<projectname>/sc/modules after a gwt compile. It calls the following line: isc.ClassFactory.defineClass("Calendar","Canvas","DataBoundComponent");

GWT compiled location: war/projectname/sc/modules/ISC_Calendar.js
Jar location: com.smartclient public/sc/modules/ISC_Calendar.js
Src location: can't find it

I suppose I can just change the javascript file in the jar I'm using, but that doesn't really solve the larger problem. I don't want to worry about running into namespace issues down the road

A: 

Say you want to rename smartgwt's Calendar to Calendar2.

First, check out the source code for smartgwt. See here: http://code.google.com/p/smartgwt/wiki/BuildingFromSVN

Then, in the source code, open up trunk/main/src/com/smartgwt/client/widgets/calendar/Calendar.java. Find this code snippet:

public Calendar(){
    scClassName = "Calendar";
}

And replace "Calendar" with Calendar2.

Now compile the source. Consult this link again to help you compile: http://code.google.com/p/smartgwt/wiki/BuildingFromSVN.

Take the resulting smartgwt.jar and open it up in a jar editor. Navigate to com.smartclient public/sc/modules/ISC_Calendar.js and open it. Find this code snippet:

isc.ClassFactory.defineClass("Calendar","Canvas","DataBoundComponent");

And replace "Calendar" with Calendar2.

Next, in the same file, do a find and replace. Replace isc.Calendar with isc.Calendar2. Also do the find and replace in ISC_Core.js.

Now save the jar. The calendar should be functional and the window.Calendar namespace will be untouched.

Tyler