Some people stay away from JavaScript, and some should be kept away. This is all very zen like, but is a problem when you need to use something like the excellent YUI in your application, and your fellow coders fall into one of the categories outlined above?
Well is you use JSF, you can write your own custom components. JSF 2 makes it really easy to write components (either composite components or Java based custom components).
I started experimenting with JSF 2 custom components sometime ago, and the simplicity of writing them compelled me to do something ‘cool’ with the new power. So friends, you have YFaces.
YFaces is BSD licensed and available on Sourceforge. I just launched it, so the only component here is Tooltip yet, but expect to see more real soon. I’ll post details of the inner workings as soon as I get some breathing time. Meanwhile, here’s y:toolTip in action.
The markup:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:y="http://java.sun.com/jsf/custom/yfaces">
<h:head>
<title>Phase Listener</title>
</h:head>
<h:body>
<h:form>
<h:commandLink value="Welcome" action="test" id="someId" title="Sample Fallback">
<y:toolTip text="And this is modified long tooltip text. One day, we will get this through AJAX
"/>
</h:commandLink>
</h:form>
</h:body>
</html>
Produces this,
(The mouse cursor is hidden due to the windows ctrl+prt Scr, but you get my drift right?)

Tooltip in Action
July 28th, 2010 by Akshat
Here is a nice little blank.war all ready for your creative juices to draw a pretty picture on. As an added little something, it has Spring, Log4J, JSF 2, Jetty and basic Acegi security thrown in the mix. Plus, it’s all managed by good ol’ Maven. Yes people, this is your lucky day.
Download the project files here.
Here is what I did to create the war using the latest Java, Eclipse with M2Eclipse and Maven.
- Create the project
- Fire up eclipse. Create a new Maven project (Skip archetype selection, enter groupId and artifact Id and click finish).
- Set the dependencies
Add the dependencies for JSF, Servlets, log4J, spring framework and acegi.
com.sun.faces
jsf-api
2.0.3-SNAPSHOT
com.sun.faces
jsf-impl
2.0.3-SNAPSHOT
javax.servlet
servlet-api
2.5
compile
javax.servlet
jstl
1.2
log4j
log4j
1.2.16
org.springframework
spring
2.5.6
acegisecurity
acegi-security
1.0.0
compile
- Add the plugins
Add jetty-maven-plugin and maven-compiler-plugin
- Tweak the plugins
We added the maven-compiler plugin because we wanted to change the default location of generated class files. You see, the jetty plugin uses various source directory while running so we can quickly turn it on or off, and edit pages as we run them without having to package a war every time. Jetty is able to pick up the right classes, however the Faces annotation provider only seems to look in WEB-INF\classes folder, which ofcourse doesn’t exist until a war is actually packaged inside the target folder. So, we put our classes where the annotation provider is looking for them. That is, in the WEB -INF\classes folder of the source directory. This is against the Maven convention, but this gets the boat rowed without harming anyone. So, we put this line in the compiler plugin:
src/main/webapp/WEB-INF/classes
(See Tomasz Lipinski’s post at https://bugs.eclipse.org/bugs/show_bug.cgi?id=288243)
- Add log4J (in the resources directory).
- Add web.xml, telling spring to look for all files with name like *-spring-config.xml in the classpath. This helps us separate our short spring-beans configuration, and the onerous acegi configuration files.
- Even though we use annotations to define our managed beans, we still need faces-config file to define the delegationg variable resolver to make our spring beans accessible to our faces managed beans. I use Spring for my services and faces for my managed beans in the view.
- See the acegi tutorial for acegi configuration.
July 5th, 2010 by Akshat
I’m installing Ubuntu on MS Virtual PC as I write this. Why am I doing it? Because the application I work on at work runs off Java 1.4 (as does our weblogic version). Whereas, all the new libraries, IDEs and stuff run off Java 1.6 (or 1.5 at least). I tried a couple of things, but to no avail. So, I finally decided to install Ubuntu.
What will I do with the new Java version? Pay with JSF 1.2, and 2 for starters. Get a copy of Tomcat which is not about half a century old, and run the latest and greatest eclipse. Doing all this on a 2GB Latitude D610? Now that is folly.
Does anyone else have an idea, about having mutiple Java versions on the same machine? Let me know.
February 13th, 2010 by Akshat
Today the 67H was missing. I waited for 20 minutes. Did it leave early? Was it late? I don’t know. Could have been either way. Just like the 61C which I took from a few blocks away, and which left a good 5 minutes early, luckily with me on board. Total time spent in -3 Celsius? Almost an hour. What a wonderful way to travel.
February 13th, 2010 by Akshat
February 12th, 2010 by Akshat