Thursday, June 10, 2010

conditionally load jQuery-UI

      /* only load jQuery-ui if not present */  
      if (typeof jQuery.ui == 'undefined') {  
           document.write("<script type=\"text/javascript\"  src=\"http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/jquery-ui.min.js\"></"+"script>");  
           //var __noconflict = true;  
      }  
      /* if Google is down */  
      if (typeof jQuery.ui == 'undefined') {  
           document.write("<script type=\"text/javascript\"  src=\"webCentral/script/jquery-ui.min.js\"></"+"script>");  
           //var __noconflict = true;  
      }  

Forwarding objects to a new view in Spring

Sometimes it is helpful to forward a command object or view data to another view in Spring.  This is how you do it, using a SimpleFormController.

1:  protected ModelAndView onSubmit(HttpServletRequest request,   
2:   HttpServletResponse response, Object command, BindException errors)  
3:   throws Exception{  
4:    ModelAndView mav = onSubmit(command, errors);  
5:    Map<String, Object> itemGroupMap = referenceData(request);  
6:    ((ItemGroup)command).setItemCount(  
7:              _helper.getItemCount((ItemGroup)command));  
8:    itemGroupMap.put(ITEM_GROUP_COMMAND_OBJECT_NAME, command);  
9:    mav.getModel().putAll(itemGroupMap);  
10:    return mav;  
11:  }  

This method gets the ModelAndView that would normally come out of a submit, then adds objects to the model for use by the second view.

Thursday, May 20, 2010

Jetty hates spaces

When trying to run the J2ee preview in Eclipse, we kept getting a 503 "service unavailable" error even though there were no obvious errors starting up the server.

It turned out the problem was that the developer had placed their Eclipse workspace in the c:\documents and settings\.... area, and jetty gets confused when starting up in an environment with spaces in the path.

Moving the workspace to a non-space-using folder solved the problem.

Thursday, March 25, 2010

Jetty and JSPs

After enabling JSP support in embedded Jetty 1.7,  I got the following error

jetty PWC6033: Unable to compile class for JSP

I had to add tools.jar from the JDK\lib directory to get this to work properly.

Monday, March 22, 2010

Selenium Server doesn't use the newest version of ant

I'm using a neat little tool called Selenium to automate some web tests (open browser, click here, etc), and running those tests in Fitnesse.  However, when trying to integrate my tests with some load-process-these-files work that another team member had done, I repeatedly got the error

Failed executing Ant target [run-job]: The type doesn't support the "osfamily" attribute.

Googling revealed that the Ant exec type didn't get added to Ant until 1.7, so you were likely using the wrong version of the ant.jar.  But I knew that both my Eclipse Ant plugin and my installed ant at ANT_HOME were both 1.7.1.  Mysterious.

Hours of troubleshooting ensued: turning all log levels up to TRACE (omg SO SO much output), poring over classpaths, deleting every errant ant.jar on the system (even those not in classpath), fresh checkouts.

My colleague finally added the -verbose option to the commandline when running tests, and lo and behold, we saw that ant dependencies were being loaded out of the selenium-server.jar, because it was first in the classpath.  Who knew those bad boys were hiding in there?

So the solution is to place the jar last in the classpath, so ant gets picked up from something more recent first.

Nearly four days later, I can actually start work on my tests again.  Whew.  Developers have straaaange problems.

Tuesday, March 9, 2010

Tomcat integrated with Eclipse

If you're using Tomcat inside Eclipse, sometimes the processes Eclipse thinks it stopped aren't really stopped.  When you try to stop and start the Tomcat server, you end up getting errors that are something like "ports (x,y,z) are already in use."

There are usually leftover javaw.exe processes that are hanging out and actually still are using that port, even though they aren't responding to the ports' activity anymore.  Killing those off does the trick (although a reboot obviously fixes the problem too, it's a huge pain in my butt when I've got ten applications all running and just where I want them).

Monday, March 1, 2010

Gmail's prompting me for my password in Thunderbird

Even though my company switched to using Google for everything (mail, docs, etc) I just wasn't willing to give up the things that I feel Thunderbird gives me for mail sorting and scheduling.  We can have a screaming argument about this all day (and I have), but sometimes you just like the way you're doing things, and don't want to give up your tool.

Anyways, I've been struggling for a while with Thunderbird's calendar integration with Google Calendar-- every once in a while, it will prompt me over and over again for my password, and even though I am SURE I am typing it right, and have checked the "please will you please PLEASE remember this in the future" box, it keeps popping up the password prompt.

And man, if I thought I had some reasons to like Seth Godin before, hoooo boy is he my personal hero now.  He has a post here that says that Google might just be getting stuck on a captcha issue.  And sure enough, that fixed my problem on the first try.

So there is a hidden link that takes you to a little captcha prompt, which apparently resets the flag that says you might be someone suspicious.

Good stuff.