My Tapestry Inspector has changed!

Hey!
What happenned to my little buddy?
Why did he stop moving?
Why did he stop trying to catch-up with all the resizes I was making?
Grrrrr, I really liked his silly behaviour, it was funny, it was cute…
I liked the way he moved up and down, always heading for the bottom right corner of my Firefox, sometimes hiding, sometimes not, sometimes even scrolling down the browser!

He was full of life!

But now, he sits still wherever you instuct him to. He’s not fooling around
any more.

And we all know who’s responsible for this. It’s his father, Mr Howard!

After making an announcement, he briefly went on to punish his child. A script was removed, some styles applied and the fix was complete.

I can only guess at the child’s last words…
– Hey father, what are you doing? I promise to grow up, I promise to never miss that lower right corner again…

RESPECT THE INSPECTOR

Update with 3 new components

Yesterday, I’ve updated the $TapFX$ project with 3 more components.
I already had them and used them in my project, but i just now managed to add
them to this public library.

The new components are nothing special:

  • ConfirmPageLink and ConfirmDirectLink popup a javascript alert when click, prompting the user for a confirmation in order to go on. The confirmation text is actually taken from the localized resources of the current page.
  • ShowItems displays a list or an array or … anything. You can specify a separator which will be placed in between. The default separator is the comma (,)

2 more components for Tapestry

Just added 2 new components into TapFX ( http://tapfx.sf.net ), Cache and FilteringTable.

The Cache component uses ehcache and allows caching of dynamic content generated in Tapestry pages. Just enclose an html-tapestry fragment with something like

 <span jwcid="@Cache" name="mycache" key="ognl:id"> ... </span>
 

In this example, the component will search for a cache named mycache and then for the id key. If found, it will ignore its body and output the cached content. Otherwise, the content is rendered and output as normal, but also stored in the given cache with the specified key. Each cache properties are controlled from the ehcache.xml found on your classpath.

The FilteringTable component is a drop-in replacement for contib:Table ( which it uses under the hood ). I’ve already discussed this component in previous blogs and its main purpose is to visually enhance its replacement. It shows navigation controls (using assets for the next, previous, first, last links) both at the top and at the bottom of the table. It can also display a small Form with a TextField near the top navigation control which can be used in order to allow the user to filter the data presented.

My next plans are to provide components for displaying cache statistics and to further enhance FilteringTable with export capabilities.

Installation info is available at the project’s web site.

Allowing Tapestry components to contribute CSS

It has always been easy to contribute javascript from a component to a page in Tapestry. The Body component included in Tapestry framework is responsible for gathering all contributed javascript and placing it either in body’s onLoad or exactly after the body tag.

However, instructing Tapestry to add a CSS, either from within a custom component or while in the middle of a page has always been an issue. I even remember that there was a patched Tapestry version which allowed such functionality.

Well, after reading Using JavaScript to dynamically add Portlet CSS stylesheets by Mark McLaren, a simpler solution can be implemented.

So, I just created a new Style component (included in TapFX v0.30 library) and here’s the code:
style.js

 function tapfx_addStyleSheet(styleUrl)
 {
 	if(document.createStyleSheet) 
 	{
 		document.createStyleSheet(styleUrl);
 	}
 	else 
 	{	
 		var styles = "@import url('" + styleUrl + "');";
 		var newSS=document.createElement('link');
 		newSS.rel='stylesheet';
 		newSS.href='data:text/css,'+escape(styles);
 		document.getElementsByTagName("head")[0].appendChild(newSS);
 	}
 }

Style.script

 <?xml version="1.0"?>
 
 <script>
     <include-script resource-path="style.js"/>
     <input-symbol required="yes" key="css" class="java.lang.String" />
     <body>
        <![CDATA[
         tapfx_addStyleSheet('${css}');
           ]]>
     </body>    
 </script>
 

Style.jwc

 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE component-specification PUBLIC
   "-//Apache Software Foundation//Tapestry Specification 3.0//EN"
   "http://jakarta.apache.org/tapestry/dtd/Tapestry_3_0.dtd">
 <component-specification allow-informal-parameters="no" allow-body="no">
     <description>Adds a css to the page</description>
     
     <parameter name="css" type="org.apache.tapestry.IAsset" direction="in" required="yes">
         <description>The css asset to add.</description>
     </parameter>    
 
 </component-specification>
 

Script.html

 <span jwcid="@Script" script="/net/sf/tapfx/components/style/Style.script"
 	css="ognl:page.requestCycle.requestContext.getAbsoluteURL(css.buildURL(page.requestCycle))"/>
 

I should just mention that all these work for Tapestry v3.01-3.03 for the moment.

Easy Insert for Tapestry

After getting some positive feedback for a previous blog, I decided to add the EasyInsert component into TapFX.

In the latest version (0.15, just get the jar and drop it into your classpath),
you’re able to use the following:

  • ${user.name} . This will become: <span jwcid=”@Insert” value=”ognl:user.name”/>
  • <div class=”${global.class}”>content</div> . This will become: <div jwcid=”@Any” class=”ognl:global.class”>content</div>
  • <div jwcid=”@MyDiv” class=”${global.class}”>content</div> . This will become: <div jwcid=”@MyDiv” class=”ognl:global.class”>content</div>

Anyway, I hope this proves useful to all.

Gentoo rocks!!!

Gentoo rocks!!!

Just a quick post to let you know that I’ve been running $Gentoo$ for the last few days.

It’s a great distro, really forces you to get into the way Linux works. The funny thing is how I got to install it in the first place…

Well, my win2000 box was constantly crawling (after installing .NET tools) and was in need of more ram (than my 512MB). So, instead of getting more memory, I decided to try linux, and since 90% of my projects are java I figured i would not have major integration problems (which turned out to be true). I had also remembered seeing a post at $Tapestry$ mailing list saying how good Gentoo is, so I gave it a try and it wo-r(oc)ked! My main comment for the whole process is that it’s really nice-funny to compile everything and that command line is the power!

Well, I’ve got KDE on top of it, installed Mozilla software + Eclipse + cvs, the networking tools are awesome (port, host forwarding was never easier), so it only remains to test the Mono project for .Net development.

Anyway, when you’re ready to switch, just give it a try!

About Samsung LE32T51BX

About Samsung LE32T51BX

I’m thinking of buying this TV, but I cannot find anywhere on the net if it
supports PIP (Picture in Picture).

So, I’m writing this in the hope that someone can help me…

Cross-site caching of javascript libraries

Cross-site caching of javascript libraries

This is a proposal for extending the script tag of HTML.

The purpose of this proposal is to allow browsers to take advantage of the many great javascript
libraries that are now in common use (prototype, dojo, scriptaculous, e.t.c.) by many different sites
and minimize bandwidth – download times.

The idea is, since I already have (in my browser’s cache) the X javascript library (because site Y uses it),
why do I have to redownload it while visiting site Z ?

So, I propose adding a hash attribute to the script tag. A browsers behaviour will go like this:

  • if a script tag doesn’t have a hash attribute, continue as normal.
  • if there’s a hash attribute, check our global javascript cache.
    • If found, use library from cache.
    • Otherwise, download library and use it. Also, compute its hash, and if it matches the hash attribute add
      it in global cache.

So, what’s your opinion on this? Do you see any potential (security) problems?

Thoughts on Hibernate and JDO

Thoughts on Hibernate and JDO

I’ve been using Hibernate for many years, but only recently did I decide to take a look at JDO. It was Pojos in Action that had me investigating JDO (the book actually covers both technologies).

Anyway, I really like it so far, though I’m not really thinking of switching to it (yet). I’m using the JPOX implementation for the moment, but if rumours are true, I may also try KODO.

From what I’ve seen so far, both technologies have similar capabilities. JDO has this nice idea of fetch groups though, which is useful if one does not want to use the open-session-in-view pattern (or the exposed domain model as Pojos in Action rightfully calls it). But JDO also imposes an enhacement stage in your code-compile-deploy(test) cycle. So, assuming similar capabilities, how can we compare these two?

Well, we can first take a look at each API and secondly compare performances.

  • In this case, the APIs are quite similar. At least for typical usage, I would say that the only thing that differs is the naming of some objects and methods. And as is, I prefer JDO’s PersistentManager, makePersistent(), detachCopy() to Hibernate’s Session, save(), initialize()
  • Regarding performance, I don’t yet have an opinion of my own nor by others. I will try to find articles on this + do my own tests – after all it’s just a mater of writing new DAOs and changing a few Hivemind configurations. But anyway, this looks like a difficult battle for Hibernate. Hibernate is really up against a specification here, which means it has to compete with every single JDO implementation.

I wouldn’t dare making any predictions on what will happen (i’m not even familiar with Hibernate’s or JDO’s future roadmap). But what if Hibernate eventually becomes YAJI (yet another jdo implementation) ? Would this be bad for us users?

On Helios plane crash

On Helios plane crash

Just a few days after returning from Cyprus back to Athens,
a terrible plane crash took place, killing 121 ppl. Fact is I was near the location
of the crash when it took place. God bless all those involved.

Some interesting links on the subject: