Posts

jQuery Floating Header Plugin v1.1.0

After many bad versions and patches on the plugin i've managed to actually test it with a bunch of browsers and i must say that it's working pretty good. There are of course still some issues on IE6, but since everyone hates that browser i don't really care. Check out the plugin on my old post , or on jQuery.com , or at the new google code project page for all my little projects.

jQuery floating header plugin 1.0.6 released

Finally the plugin have some support for IE6 and 7. Read more on the current project page . I've also decided to gradually migrate the project to my Google Code project .

Eclipse Resource Filtering

Today i found a solution to the single most irritating thing with Eclipse. To not be able to filter away resources from the Open Resource dialog. This was of course possible but I've never even thought about it until a coworker passed me this link . I quote: The trick is to open the "Navigator" view, right click on the folder to be ignored, and check the "Derived" property. This option informs Eclipse that this folder consists of generated resources that should not be directly edited. Once this is done, the "Open Resource..." view will only show matches that would be relevant to the developer.

Getting a FacesContext from a GWT service

I'm working on a project where we needed to integrate JSF and GWT. To be more specific, we needed to have access to JSF beans in the GWT services. Because I missed the methods getThreadLocalRequest() and getThreadLocalResponse() in RemoteServiceServlet, I had to search quite a bit before i found an answer to this problem. So to save others some time i post the class i came up with. Most of the code is taken from an article at ocpsoft.com which also points out how important it is to release the context when you're done with it. The big difference are the lines, UIViewRoot view = facesContext.getApplication().getViewHandler().createView(facesContext, "gwtViewID"); facesContext.setViewRoot(view); , which sets the view root. If no view root is set you can't use, for instance MessageBundles. The getBean methods are only convenience methods for retrieving beans by name. /** * A substitute for RemoteServiceServlet that has access to the FacesContext. */ @Sup...

How to create a jQuery plugin

I tend to write everything i do in JavaScript as a jQuery plugin. Even if it's mostly useless, i think it's a convenient way to encapsulate the code. In this post I'll show how to make a simple plugin that replaces the background color of an element when the mouse hovers over it. In real life you would probably want to do this with CSS pseudo-classes . Step 1 - Get ready All plugins i write always starts with the same template: (function($){ $.fn.backgroundHover = function(options) { return this.each(function () { // Code goes here }); }; })(jQuery); Line 1 and 7 are only there to protect from $-function overloading by using variable scoping . On line 2 the plugin function is defined in the prototype of jQuery. fn is just an alias for prototype . Since a plugin can be applied to many DOM nodes in one call, we must loop through every element on line 3. Step 2 - Get Set Now we just need to write the actual code for the plugin. First we gonna a...

Simple canvas 2d physics

We were out playing pool a couple of nights ago. Instead of betting money on the games we used code-hours. I'm not very good at pool so in the end i was lucky to only owe my friend one code-hour. He wanted me to code a physics "demo" on a canvas element. Since i only had one hour to code we limited the "demo" to 2d and circles :) The implementation is quite ugly and the physics formulas are pretty much taken from an article at gamedev (which i can't find at the moment). Demo The result of my code-hour can be found at:    http://static.slackers.se/pages/javascript/canvas-simple-2d-physics/

Switching to Blogger

Image
After a couple of hours work I've switched platform to Blogger and it was easier than i thought. As a bonus i upgraded the theme to something with a little more colors. I've got the feeling that my old style (on the image) wasn't optimal, or as Mike put it , For the love of God, put some style on your links so we can see them Wordpress is a great platform with a lot of plugins and features. The only reason i switched was that I just don't have the energy to host Wordpress on my own server. Update to new versions, tweak the skin, fix plugin versions. Some of the posts don't quite work after the switch but i will go through and fix all of them, in time.