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.
The moose likes JSF and the fly likes Backing bean vs custom component Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Backing bean vs custom component" Watch "Backing bean vs custom component" New topic
Author

Backing bean vs custom component

arjan tijms
Greenhorn

Joined: Jan 22, 2006
Posts: 5
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

Joined: Jan 24, 2006
Posts: 34
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Backing bean vs custom component
 
Similar Threads
Displaying values in the datatable!
how to use TreeSelectionListener in a tree ?
Problem with h:dataTable
Problem with adding jsf component programmatically|dynamically
Facing problems with x:dataTable and x:dataScroller