function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dradtkedradtke 

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.

 

<apex:dataList>
  <c:Item .../>
</apex:dataList>

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?

bob_buzzardbob_buzzard

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?

dradtkedradtke

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.

bob_buzzardbob_buzzard

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?