Code till you … drop
andyhot
This user hasn't shared any biographical information
Posts by andyhot
Allowing Tapestry components to contribute CSS
Mar 21st
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
Mar 21st
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!!!
Mar 21st
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
Mar 21st
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
Mar 21st
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
Mar 21st
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
Aug 18th
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:
2 hours lost due to SF upgrade!
Aug 9th
2 hours lost due to SF upgrade!
Well, I’m back from vacations in Cyprus (Protaras for sea, Kalopanagiotis for mountain) and I was going to add some new Tapestry components to my sf project, tapfx.
CVS access was not working however, and since it’s been a while since I’ve used it, i thought : ‘Hey, I must be doing something wrong here!’
So, I browsed the docs, and the first thing i see is that it’s advised not to have strange characters in your password (only letters and numbers) because the cvs might not handle them. So I thought, that’s it! I change the pass (from web), wait for 10 mins (for the change to propagate to cvs), try again, but nothing happens.
So, I figure, time to use public/private keys instead of passwords. I set everything up (was the first time i did so), and tried command line access, but again no success.
Somehow I tried different host names, i.e. cvs1.sf.net, cvs2.sf.net, and they allowed access, but this time, my files weren’t there. So, I go to the central SF page, to look for news, but i don’t find anything there. However, by complete accident, I click on Site Status and amongst others i see this:
Project CVS Service: Offline – Scheduled Downtime In-Progress
gggggggrrrrrrrrrrrrrrrr!!!!!!!!!!!!!!
Stuff to do
Apr 4th
Stuff to do
Ajax-ian thoughts…
I’ve been doing a lot of thinking on how to best
provide ajax functionality to $Tapestry$. The process seems to be as follows:
- Create a component which takes a reference to a listener method.
- Get the DirectLink URL for the listener
- Have the component emit javascript (including the URL)
- Using XmtHttpObject (and/or flavours) in javascript, get the contents of the
previous url. - Translate the response (a String) into javascript actions.
Javascript Tutorials
I need to take a look at some advanced javascript tutorials, relating
to object handling, etc. This will enable me to resolve conflicts
when a $TapFX$ component is included many times in a page.