Jeremy Zongker

Greenhorn
+ Follow
since Jul 08, 2012
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jeremy Zongker

Thanks for the reply Tim. I think I'm mostly following you, but if composite controls don't have controllers and I shouldn't get in the habit of using listeners on a regular basis, where should I store the logic to render sections of a page that are re-used frequently? The composite control itself is great for the basic layout, but you usually need to make a few decisions when rendering.
11 years ago
JSF
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.
11 years ago
JSF