I have a <h:dataTable ...></h:dataTable> with questions, and above that I have a panelgrid with three commandButtons that are invokes three methods in the backing bean. However this dataTable and filtering-buttons would be useful for me in other pages too so I extracted them to a own file. Then when I need it I include it with a parameter (the backing bean).
However it isn’t very DRY to have the same methods in multiple backing beans….so I could make a baseclass and inherit them, but they do not relate by inheritance. So would a better approach be to make a QuestionTableHandler class with these methods, then have a property to this in the backing beans? Or are there other approaches that are better
You can build
composite componentsthat allow attaching backing beans methods, etc..IBM has a guide on that topic.
EDIT:
You could consider writing a general handler with generics that then call the interface of your actual implementation where required.