Dynamic Visualforce Page Injection | Apex and Visualforce Controllers

Visualforce Page Injection

Question

A component that inserts a second Visualforce page into the current page.

The entire page subtree is injected into the Visualforce DOM at the point of reference and the scope of the included page is maintained.

If content should be stripped from the included page, use the <apex:composition> component instead.

Answers

Explanations

Click on the arrows to vote for the correct answer

A. B. C. D.

B.

The component that inserts a second Visualforce page into the current page while maintaining the scope of the included page is the apex:include component.

The apex:include component allows you to include the content of another Visualforce page in the current page. The entire page subtree is injected into the Visualforce DOM at the point of reference, and the scope of the included page is maintained. This means that any variables or components defined on the included page will be available to the current page.

If you want to include content from another page but also want to strip out some content, you can use the apex:composition component. The apex:composition component allows you to define a page template that can be reused across multiple pages. You can define the common page elements, such as the header and footer, in the template and then include the content specific to each page using the apex:define component. The content defined in the apex:define component will replace the corresponding apex:insert component in the template.

The apex:iframe component allows you to embed an external web page within your Visualforce page. This can be useful if you want to include content from another website, but it does not maintain the scope of the included page.

The apex:inputFile component allows users to upload files to your Visualforce page, while the apex:inputField component is used to create a form input field for a specified object field.

In summary, the apex:include component is used to include the content of another Visualforce page in the current page while maintaining the scope of the included page. If you want to strip out some content from the included page, you can use the apex:composition component. The apex:iframe component is used to embed external web pages, while the apex:inputFile and apex:inputField components are used for form inputs.