Implementing a Firefox Plugin for Tapestry’s Reset Service

Implementing a Firefox Plugin for Tapestry’s Reset Service
Actually, i decided to make this a greasemonkey script, instead of a full FF plugin…

So, here’s the process:

  • 12:25. Install greasemonkey. ( http://greasemonkey.mozdev.org/ )
  • 12:27 Restart Firefox
  • 12:28 Search for a good tutorial on writing greasemonkey scripts.
  • 12:32 Hmm, http://greasemonkey.mozdev.org/authoring.html is a starting point, as is the http://mozdev.elliptic.fr/greasemonkey/linkify.user.js example.
  • 12:33 Create a file named tapestry.user.js somewhere. Open it up in an editor and also in FF. Make your changes in the editor, refresh in FF and click on install to use it.
  • 12:37 After the first hello world examples, let’s create something that adds an absolute positioned div in the current page, containing a static link for the moment.
  • 12:41 I used document.createElement(‘div’) to create the div and document.getElementsByTagName(“body”)[0].appendChild(resetDiv) to add it in the dom.
  • 12:44 I can write links in the div… with the ugly way (hope Jesse isn’t reading this), i.e. resetDiv.innerHTML=’<a href=”…”>Cool</a>’
  • 12:45 location.href gives us the current url. we’ll have to hack it a bit to contruct a valid Tapestry reset url. For now, we’ll keep the url from the beggining to the last occurance of slash ‘/’ and append app?service=reset&page=Home afterwards.
  • 12:50 Done! Here’s the result.

Remember to configure the script so that it’s active only on the pages you want. Further updates might:

  • Recognize Tapestry sites and auto-enable the plugin.
  • Recognize and use the current page so that you won’t get redirected to Home.
  • Use better styling for the added div… It should be on the top of the page, with absolute positioning and semi-transparent.
  • See if this also works in Tapestry 3.

So, watch out for an update on this!

P.S.1 You have to enable Tapestry’s reset service for this to work.
P.S.2 If you’re wondering why you need this, then read on : )

While editing Tapestry’s templates (*.html) or configuration files (*.page, *.jwc, *.application, *.library) you can get instant save-refresh functionality if you disable cache (that’s org.apache.tapestry.disable-caching ). This however slows down request handling by a noticable amount and results in memory leaks because classloaders are thrown away on each request. I generally wouldn’t mind about this since it’s only used on development and it takes a LOT of refreshes before one gets an OutOfMemoryException.

But if you’re on AJAX ( read tacos or tapestry 4.1 ) then you’ll get that exception a lot more faster. So, in the last few months I’ve got into the habit of enabling cache + enabling the reset service ( that’s org.apache.tapestry.enable-reset-service. I usually keep an extra tab open in Firefox (having the url of the reset service) and whenever I make changes I hit refresh on that tab (so that all templates and Tapestry configurations are reloaded) and then return to my normal tab.

P.S.3 This was initially written in my internal TiddlyWiki, an awesome javascript-only wiki. I was really surprised when Howard recently commited (!!!) this wiki in Tapestry 5 trunk. In fact, I never knew a wiki could get itself committed! Well done Jeremy.

Netbeans5.5Beta2 bundled with JBoss4.0.4 : No way to change server port

Netbeans5.5Beta2 bundled with JBoss4.0.4 : No way to change server port

I’ve been playing a bit with Netbeans5.5, mostly due to Geertjan’s posts (esp. those describing how to build plugins supporting web frameworks). I even started nbtapestrysupport.

So, i’m on a new machine today and having decided to take a look at NB’s plugin support, i head for www.netbeans.org to download the 5.5 version. I’m however sidetracked with the plethora of the available installers… without thinking a lot, i go for the “NetBeans IDE 5.5 Beta 2 + JBoss Application Server 4.0.4 Bundle Installer“.

Installation went smoothly. After updating NB to include the subversion support, I was able to checkout from https://nbtapestrysupport.dev.java.net/svn/nbtapestrysupport/trunk/TapestryPlugin and build & run the project.

My next thought is ‘let’s see how well JBoss integrates’…so, going to the Runtime tab, right-clicking on JBoss and selecting Start results in “port 8080 already in use”. Oh well, there’s a background tomcat instance running on this pc, it shouldn’t be difficult to make jboss use another port, i.e. 7070.

Googling easily produces “change the following file:
server/xxx/deploy/jbossweb-tomcat55.sar/server.xml” and indeed, if i then issue “jboss_dir/bin/run.sh” it picks up the change and it works.

BUT, from within NetBeans it doesn’t and there’s no way to make it work… googling doesn’t help either… it’s as if there’s a hardcoded configuration somewhere inside NB’s JBoss integration code… Let’s look for a workaround then. Right click to “Add Server” and then browse to the JBoss installation folder is quite interesting. NB informs us that the configured port is 7070 (cool!) but also that ‘The domain instance you want to add already exists’ (sad but correct).

My question of course is, since the instance already exists and since it can indeed read the 7070 value, why doesn’t it use it ???

Anyway, I ended up renaming the instance (just a folder rename) which allowed me to add the server in the previously described way. And this leaves us with:

Why, oh why, can’t I delete (or even rename) the original (and non-working) JBoss server registration ???