Unsurprisingly, Internet Explorer 8 broke yet another feature of the web.
Embedding HTML Document in an IFRAME With GWT
While working on a recent project in GWT, I needed to embed a full HTML document inside an IFRAME. And I didn’t want to specify a remote URL for the IFRAME - I actually wanted to shove the HTML content directly into the IFRAME.
Subversion: File or Directory Is Out of Date; Try Updating
I recently started encountering a strange problem with Subversion on one of my machines. In larger commits, I would suddenly get an error:
1 2 3 4 5 |
|
Although I was positive the file(s) were up to date, I ran an svn up just to be safe:
1 2 |
|
Nothing changed. If I tried to commit again, I would get the same out of date error. Eventually I figured out that if I delete the folder containing the problematic file, ran svn up to restore the working copy and re-edited (or restored from a backup) the modified file, the problem went away. This suggested an issue with the Subversion metadata, but this blog post from Pageworthy describes a much easier work around:
Delete the all-wcprops file from the .svn metadata folder for the offending file.
In other words, if Subversion complains about src/com/mycompany/Foo.java
, then delete src/com/mycompany/.svn/all-wcprops
.
- OS: Mac 10.6
- IDE: Eclipse 20090920-1017
- Subversive Team Provider: 0.7.8
- Subversive Connectors: 2.2.1
- SVNKit 1.3.0: 2.2.1
- Subversion: 1.6.6
Kubuntu 9.10 Dual Monitors
A few months back I got a new 12.1” System76 Darter laptop and I finally decided to setup dual monitors on Kubuntu 9.10 (Karmic Koala).What I wanted was to have my laptop LCD on the left at 1280x800 and my ViewSonic LCD panel on the right running at 1680x1050. Apparently I’m old-skool, because I’m used to hacking away at my xorg.conf
just to get dual monitor support to work under Linux. Somehow I never knew about xrandr, KRandR, etc.
Spring PropertyPlaceholderConfigurer Beans
So I found a scenario today where we had two different PropertyPlaceHolderConfigurer
beans declared in two separate XML files. Unfortunately, the second property file wasn’t getting loaded, so we would get errors about Spring being unable to resolve particular properties.
I found this great post summarizing the solution:
http://dotal.wordpress.com/2007/09/14/mulitple-propertyplaceholderconfigurer-configurations/
Basically, you have to update the definition for the first PropertyPlaceHolderConfigurer
bean that gets loaded and add the ignoreUnresolvablePlaceholders
property:
1 2 3 4 |
|
DRY Associations in Rails
I found a nice little article from a few months ago on The Rails Way. Written by koz, Assocation Proxies talks about some Best Practices for using assocations within Rails. I really felt the suggestions hit the proverbial nail on the head in terms of following the DRY principles. The first suggestion was on the best way to restrict access to user specific information. It’s incredibly useful to take advantage your RESTful patterns and make a single call like:
1
|
|
Of course, I also loved the final suggestion in Case Three: using a has_many with a condition on it:
1
|
|
Excellent!
Struts Redirect w/Parameters Part 2
In an earlier post, I described a class to handle redirects in Struts and passing parameters along. That technique is not necessary; as of Struts 1.2.7, you can use the ActionRedirect
class instead.
Here’s a basic example from inside the execute method in an Action.
1 2 3 4 5 |
|
The ActionRedirect
class is basically the same as my ForwardParameter class and is probably preferable.
Exception Handling Framework for J2EE Applications
OnJava has an interesting article on generic approach to handling exceptions within a J2EE framework. The basic idea involves creating a generic base class for exceptions and a basic handler for all requests that includes dispatcher to pass the request along to the appropriate method.The fundamental idea is fairly sound and the idea of including a context to allow reuse of generic exceptions seems like a strong idea.
My concern is that in a large project, the use of a “context” may make it difficult to figure out which specific message code is used in a given place. The generic exception handling is especially beneficial for the “this should never happen” cases where there isn’t much the app can do about the exception, but should still handle it in a robust manner.
Struts Redirect w/Parameters
If you have a Struts Action servlet and you want to redirect to another page, the standard Struts technique is to return an ActionForward and setup an appropriate forward entry in struts-config.xml
:
1
|
|
Unfortunately, this doesn’t provide a mechanism for passing request parameters to the target. So what can you do if you want to redirect to another page and pass some parameters along? You use an additional class:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
|
Here are some examples of using ForwardParameters:
Long form:
1 2 3 4 5 |
|
Concise form:
1 2 |
|
Ultra concise form:
1
|
|
This is based on a suggestion I found on Experts-Exchange by dualsoul.
Edit June 5th, 2006:
As someone just pointed out to me this morning, you can use the ActionRedirect
class instead of my ForwardParameters
class. According to the JavaDocs, ActionRedirect
was added in Struts 1.2.7 and is:
… a subclass of ActionForward which is designed for use in redirecting requests, with support for adding parameters at runtime.
Prefactoring
Prefactoring is the process of using your experience to write better code. Specifically, writing code that can be refactored more easily, that is easier to read and easier to maintain.
The article is available on oreillynet.com:
What Is Prefactoring? by Ken Pugh, author of Prefactoring.