+ Start a Discussion

Component - how to call or reference the containing page?

I'm working on an application that makes a query and displays the results as a list of custom components, e.g.


  <c:Item .../>

Each Item component contains a "more info" link that should display a modal dialog containing the additional information. I've found a tutorial on how to do a modal dialog in apex and css, but the outputPanel and css needs to be contained in the main page. The problem is that the Item component has its own controller, and I don't know how to reference the containing page/controller to tell it to display the item's detail.


Any advice?


The only way that the component can know about the parent page/controller etc is if the information is passed through via an attribute to the component.  Do you need to hit the controller, or can you call some javascript or similar?


I did actually try passing in the instance of the outer controller as a parameter, but the compiler didn't like it and ended up reporting exceptions with no message attached.


I haven't yet tried anything with javascript, but it's something I can look into if it's not possible in pure apex.


It should be possible to pass the controller instance to the component - although it rather defeats the purpose as it ties the component to a particular controller (or controller type).


You can pass action methods as attributes - does that help?