Showing posts with label JSF. Show all posts
Showing posts with label JSF. Show all posts

Tuesday, February 16, 2010

JBoss Tools Eclipse plugin content assist lessons

I learned a couple lessons in the process of making JBoss Tools Eclipse plug-in to do content assist (where you type ctrl-space to get code suggestions). This is mostly about JSF component libraries.

First of all, in order to get content assist for JSF components, you must have the TLD file in your class path. We are using Richfaces libraries, and all its components get content assist. The ones I had trouble with are jsf-core and jsf-html, the f: and h: tags by default. Oddly enough though, with all the JSF libraries I have on my class path, none of them had packaged the TLDs for these two. I made a jar file and put jsf-core.tld and jsf-html.tld in the META-INF folder to get this working.

Another lesson learned is that the name space URI has to match exactly with the TLD's. I mean exactly. Kind of obvious, but easy to miss when trouble shooting. I added Openfaces like this xmlns:o="http://openfaces.org" in the first place and it didn't work, because it is expecting a "/" at the end. So the correct syntax is xmlns:o="http://openfaces.org/"

Tuesday, December 15, 2009

jboss tools 3.1M4 code assist/content assist not working with JSF core and html?

I was playing with jboss tools 3.1M4 and only found out that I am not getting content assist (CA) for the JSF core and html tags. All other namespaces work fine, like richfaces, seam, ajax4jsf etc. How could that be?

My first thought was that the TLDs for core and html are missing. So I manually added the core and html XSD into the XML catalog, restarted eclipse, didn't do it.

Next I found a couple wiki pages (here and here) talking about how content assist works in jboss tools 3.1. They are good how-to but not helping me out. I was ready to dive into the source code and examine the Knowledge Base CA processors.

Then something stroked my mind: is it because my project is not considered JSF projects? I right clicked my project and in the Jboss Tools menu selected "Add JSF Capabilities...", and voila, that made all the difference.

I spent about 3 hours trying to figure this out. This reminds me again: more often than not the solution is much simpler than one imagined.

Thursday, January 29, 2009

JSF converter implementation notes

SEAM's built-in converters are big time-savers, especially the s:convertEntity and s:convertEnum. Now the needs of rolling out customized JSF converters are few and far between, I just want to jot down the patterns I had used in case I forget.


  1. take the entity's primary ID as string, and load it from persistence media by ID to convert back to object

  2. implement an algorithm that can encode the object into a unique string, and reconstruct the object by parsing the string

  3. Construct a map of strings and objects. Because converters are instantiated on demand, you have to save the map in a backing bean whose life-cycle spans over requests. The map is nested in the h:selectOneMenu component using f:attribute tag, so that the converter can get a handle of it.


SEAM Howto - end conversation and go back to the previous page

In web application it is often desirable to provide a "Cancel" button in a function area which will redirect the user back to the page they come from.

In SEAM if the function area is wrapped by a conversation, then there are two ways to archive this navigation effect, depending on whether or not you need to do clean up when ending the conversion.

If there is no clean up to be done, you can use s:link or s:button as shown in the example below. The action is invoked first. The view attribute is rendered if redirect did not happen after the action invocation.

If there is clean up to be done, you can archive this in pages.xml file with a navigation hack.




In your pages.xml: