Tuesday, March 2, 2010

Problem with ui:repeat and el bracket operator

You'll get a java.lang.IllegalArgumentException: null when try to access a property in an object through an el bracket operator thats inside a <ui:repeat> component. Here's an example:



There's a concurrency issue with the var in the <ui:repeat> and the foo object inside the el bracket. The el expression is trying to evaluate foo before the var in <ui:repeat> is setting it. One solution to this problem is to change <ui:repeat> to <a4j:repeat>. RichFaces's <a4j:repeat> will set the var before the el expression evaluates foo.

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.

Tuesday, January 26, 2010

Hint Text Within RichFaces Calendar

Here's a way to have a hint text within RichFaces calendar component. It's not the most elegant way to do it, I'm sure there's a better way. Also this solution takes care of having multiple RichFaces calendar on one page(e.g. ui:repeat).

css


JavaScript


xhtml

Multiple RichFaces Modal with Same Shortcut Key to Close

If you have more then one rich:hotkey with the same key, one of them gets ignored. Here is a trick to having multiple RichFaces Modal Panels with the same shortcut key(ESC) to close.

JavaScript


xhtml