I'm new to
Java development and am coming from an ASP.NET background, so
JSF seemed like a good platform to use. Templating makes sense and works more or less like ASP.NET master pages, but I'm having the hardest time getting my head around Composite Controls which I assumed were roughly equivilent to ASP.NET User Controls. I would like to pass them a data object, and have code tied to the control responsible for rendering it. This seems like a simple and common task, but I'm running into two major problems.
#1 I don't know where to store the logic for the custom control. I can put it in a Bean, but there doesn't seem to be a way to tie a Bean directly to an instance of a composite control. The best I can really do is @RequestScoped which ties it to the page request. But what if I want to have 20 copies of the control on the page, each with their own data objects to render? What's the proper way to tie code to the composite control?
#2 There doesn't seem to be any reasonable way to interact with the control from the code for my page. Say I want to pass my control a Customer object from the page to the composite control. How would I go about doing this? All I can really find is ways to pass simple types and Strings to the control from the pages .xhtml file, not from code. How do I get a reference to the controls bean from the code for my page?
Am I trying to use these composite controls in a way they're not designed for? Is there something else I should use instead (beside an include) for housing code to render an element of a page that is re-used? I'm sorry for the basic questions, none of the tutorials I can find seem to cover this.