What are design options for the following requirements?
- End user specifies the text of a Modal window to be something like:
Hello [User Full Name], Because you chose [Case.FieldA] goto this <a href="hyperlink.html">hyperlink</a>.
- A Visualforce page gets this text from either a Custom Metadata or email template or something declaratively accessible.
- The Modal renders the text in pretty HTML.
- The Modal will capture the onclick event of the hyperlink and create a custom object (CaseInfo__c) record with the HTML link, in the text, set in the CaseInfo__c.Link__c field. Would prefer to not use JS if possible.
My design (which I don't like):
- split the text message into the HTML portion and the dynamic portion (which contains the User Name and Case field info.)
- Create a Visualforce Form component which contains OutputPanels. The "Save" button in the first, initially visible OutputPanel, will rerender a second, initially hidden OutputPanel (Modal).
Here's a portion of the code:
<apex:outputPanel layout="block" styleClass="modalMessageText"> Hello {!$User.FirstName},<p/> Because you chose, "{!Case.FieldA__c}", <apex:dynamicComponent componentValue="{!restOfMessage}"/> </apex:outputPanel> <apex:commandButton value="OK" title="Close the modal" action="{!closeModal}" rerender="modalWin"/>
The dynamicConmponent in the above page is supported by the associated page controller, which pulls the HTML portion of the message from the Custom Metadata record. This example has a simple link but the design should allow for a more complex (i.e. multiple links, multiple paragraphs, etc..) type of message. My current design doesn't address the forth bullet... besides being a hack.
Any helpful direction or insights would be most appreciated.