Wednesday, February 3, 2010

Links and rich:menuItem

One of the shortcomings of links and rich:menuItem is that you have to define the url in two places; in the onclick attribute and in the inner text.



The reason for adding the url to the onclick is so that user can click anywhere on the highlighted menu rather then just the text portion. Well...as one of my tricks in the bag is to wrap the whole menu item with an anchor using jQuery's wrap. Then you only need to have one url to keep track of and maintain.

Monday, February 1, 2010

RichFaces Client Functions

RichFaces comes with four client functions to take control of a particular component. They are:

  • #{rich:clientId('id')}
  • #{rich:element('id')}
  • #{rich:component('id')}
  • #{rich:findComponent('id')}

#{rich:clientId('id')}
Suppose you have this on your page:


The following:

Would produce this:


#{rich:element('id')}
The following:

Would produce this:


#{rich:component('id')}
The following:

Would produce this:


#{rich:findComponent('id')}
Then there's #{rich:findComponent('id')}. It's cool in that it's another way to access the component on the client side. For example, lets say you want to get the value of the combo box on the client side rather then from the managed bean. You can do so like this:

When you selected a different value from combo box, it would output what you selected.