0

I have a custom VF page which is added to a section in the page layout of an object.

What I'd like to achieve is to add dynamically generated HTML code to my custom VF page.

The HTML is dynamically generated via apex code in the beforeInsert() method.

The HTML code must be generated in the beforeInsert() method because the HTML depends on the invocation of another method.

How my apex code from the the beforeInsert() method can access my custom VF page to set the HTML code inside the VF?

I need to include the HTML which is dynamically generated via apex code and to include it in my VF page.

Please advise how it can be achieved?

1

You can use <apex:outputText escape="false" value="{!variable}" /> to achieve this flow.

Or you can also use JavaScript to achieve this

// Select the element
var childDiv = document.getElementById("div");
childDiv .innerHTML += '' //Paste the HTML here
  • @Thushar Thank you for your answer, however I'm not sure you understood my question. By adding outputText it is not clear to me how my HTML generated via apex can be put into a VF page. What I need is to transfer my HTML which is dynamically generated via apex and to include it in my VF page. Please advise how it can be achieved? – lemdev Jan 10 at 13:52
  • @lemdev is your apex code is different then the VF page? if yes then I don't think your requirement is quite possible, because both will act as different thread. – Tushar Sharma Jan 10 at 14:13

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.