Tag Cloud Component in JSF

After spending couple of hours and playing around with some jsf component features tweaks i was able to develop a Tag Cloud Component.

Here are few things this you might clear some confusions which i faced when writing this component in jsf.

Firstly, you need to decide do you need a seperate class for renderer or you can render in the same component class if you are not planning to reuse the renderer for other things.

Second writing jsf component will be a little more simpler if you are using jsf-facelets.

Now if you are doing this is Jsf 1.1 then while writing the tag class you need to take care that any attributes defined should be declared as String no matter what is the input/Output type of the component. whereas same thing if you are doing in 1.2 then all attributes has to be defined as ValueExpression.

eg: if you are creating a tag for TagCloud Component in jsf 1.1 look at the following code.

public class TagCloudTag extends UIComponentTag {

public String labelsMap = null;

public String getlabelsMap() {
return labelsMap ;

public void setlabelsMap(String labelsMap) {
this.labelsMap = labelsMap ;

// Associate the renderer and component type.
public String getComponentType() {
return "com.thoughtclicks.component.TagCloudComponent";

public String getRendererType() {
return null;

protected void setProperties(UIComponent component) {
if (!(component instanceof TagCloudComponent)) {
throw new IllegalStateException(
"Component "
+ component.toString()
+ " not expected type. Perhaps you're missing a tag?");
TagCloudComponent tagCloud = (TagCloudComponent) component;
if (labelsMap!= null) {
if (isValueReference(labelsMap)) {
ValueBinding vb = getValueBinding(labelsMap);
tagCloud.setValueBinding("labelsMap", vb);
} else {
throw new IllegalStateException(
"The value for 'tagCloud' must be a ValueBinding.");

public void release() {
labelsMap= null;

private ValueBinding getValueBinding(String valueRef) {
ApplicationFactory factory = (ApplicationFactory) FactoryFinder
Application application = factory.getApplication();
return application.createValueBinding(valueRef);

Similarly, if you are writing the same component in jsf 1.2 then you will need to change the attribute labelsMap to ValueExpression also don;t forget you need to extend "UIComponentELTag" instead of UIComponentTag and corresponding changes to set properties method.

For any other supporting code you can write me at : rahul.juneja@thoughtclicks.com.