• Post Reply Bookmark Topic Watch Topic
  • New Topic

Backing bean vs custom component  RSS feed

 
arjan tijms
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

What would be the best approach?
 
Saskia de Jong
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!