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
AffinaquestAffinaquest 

Retreiving HTML text from static resource

I am trying to build some help pages for use in Visualforce pages.  My plan is to build several pages in HTML, each as a separate document, zip them into a folder, and then upload the folder as a static resource.
 
Is there a way that I can extract a single text document from a static resource?  I see a way to do this with images, but can't find any examples of how this is done with documents.
 
Secondly, if I am able to extract the HTML, will I be able to display the HTML document properly or will I only be able to display the HTML and its tags as text?
 
Any other ideas on how this might be accomplished?
 
Thanks in advance for your help.
 
Jeff
dchasmandchasman
Jeff,

All of the documents/folders that are in your hierarchical static resource are fully web addressable using urlFor() and $Resource like you would for an image and any browser approach to retrieve thing via HTTP will provide access (e.g. iframes or an ajax call etc). If you are looking to combine these documents server side we do not currently have a mechanism to do that directly. You might be able to leverage the recently added HttpRequest/HttpResponse support in Apex Code to retrieve the things you need to via apex code in a custom controller or controller extension - I have not had time to try that out myself just yet but in theory it should work and making a simple HTTP GET request is pretty basic.

As for displaying HTML - if this is all done server side the onyl thing you'll need to leverage in your VF page where you are injecting the content is to use <apex:outputText value="{!content}" escape="false"/> which will suppress VF's normal auto HTML escaping...
AQAQ

Doug,

Thanks for your help on this.  I've investigated several ways to do this based on your post and suspect I'll just use an iframe referencing a website with the appropriate information.

I'm a little reluctant to use the new httpGET feature because it requires entering endpoints as remote proxy settings.  Since I want to package my application on the AppExchange I would need to be able to include these remote proxy settings in the package and I don't think that can be done.

Jeff