This week's book giveaway is in the General Computing forum. We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line! See this thread for details.
I wonder what the general opinions are on implementing GUI behaviour in backing beans instead of custom components. As a small example, I have a panelgrid with a few commandlinks and images of flags in them that I would like to show some marker for the selected language.
One aproach would be to let a backing bean discover the currently selected component and dynamically build a matching serie of column CSS classes. E.g.
With the relevant parts in the backing bean being:
The other possible aproach would be to create a custom component that tracks the selection of its own commandlink children. Surely this is not that difficult, but going down that road I'll probably end up with lots of different custom components for all those little GUI behaviours on every page.
It would seem that creating new components is the way to go. Atleast, this is what I normally do in Swing. However in JSF its not exactly trivial to create new components, especially not if you would like to include a JSP interface (taglib tag).
In most JSF textbooks it is said that components should only be written by, well... component writers. "Regular" JSF programmers (whatever that means) don't write JSF components, they just consume them.
Therefore, I think you should stick to the backing bean approach.