0

I'm uploading a component and the controller class to the static resources and trying to use it in a vfp. But when I save the vfp with the reference, it throws an error that the component does not exist.

enter image description here

I've tried uploading them as compressed zip files and also as stand-alone files.

<apex:page>
  <h1>Congratulations</h1>
  This is your new Page

    //Stand-alone files
    <!--<apex:includeScript value="{!$Resource.HelpboxComponent)}"/>-->
    <!--<apex:includeScript value="{!$Resource.HelpboxController)}"/>-->

    //Zip file
    <apex:includeScript value="{!URLFOR($Resource.Helpbox, 'Helpbox1.0/HelpboxComponent')}"/>
    <apex:includeScript value="{!URLFOR($Resource.Helpbox, 'Helpbox1.0/HelpboxController')}"/>

    <c:Helpbox Tips=""/>
</apex:page>

Can components from static resources be used or I'm making a mistake in the static resource reference. Thanks.

4
  • 1
    A component is not a static resource it is a component. You will have to create the component in the org before you can use it.
    – Eric
    Commented Jan 13, 2015 at 20:56
  • @Eric Yes I know a component is not a static resource. I think the question is not clear. For example, when I get a zip file with components, classes and pages. Do I have to extract the components and copy the code in my org. Can't I upload that zip archive in the static resource and utilize it?
    – Seesh
    Commented Jan 13, 2015 at 21:04
  • A static resource is a place to store Resource used by the page, data for test data, static config data, etc. Actual metadata MUST be created in the org in order for anything coreference it.
    – Eric
    Commented Jan 13, 2015 at 21:08
  • Thanks @Eric. What if the zip file contains the component and the metadata.xml file?
    – Seesh
    Commented Jan 13, 2015 at 21:16

1 Answer 1

0

Putting a component and class in a static resource does not make it available in the organization. The point of static resources is to deliver, well, static content. By definition, a component is not static content. I would download the static resource and individually copy the code into respective components, classes, and pages as needed.

5
  • Thanks @Bradley. When I download zip archive from GitHub repository, it contains many components and classes with meta-xml files. If I'm following you right, those code had to be copied into org and used?
    – Seesh
    Commented Jan 13, 2015 at 23:01
  • You are correct. Code in a static resource should be reserved to JavaScript and CSS. Visualforce and Apex must both be compiled, so they should be added to the organization as metadata. If your package has a small number of components, you might be able to copy and paste the code from the files. If you are needing to add a bunch of components, it may be worth attempting to use a migration tool like ANT or Eclipse. Commented Jan 14, 2015 at 5:27
  • Exactly @Bradley. I'm using eclipse to import large code blocks. But I was wondering why are we using static resources only for JS and CSS but not classes and components. Thanks for clarifying.
    – Seesh
    Commented Jan 14, 2015 at 5:53
  • JavaScript and CSS are not compiled. They are sent directly to browsers for use in the browser. Apex and Visualforce are compiled languages that get broken into 'stored procedures' when they are saved. In other words, when you save the files into Salesforce, they get broken down into simple commands for the servers to execute when needed. In order for this procedure to take place, there are very specific ways to save these files so they are compiled correctly. Commented Jan 14, 2015 at 5:56
  • Yes. I got it now. JS and CSS are client-side (browsers), whereas Apex and VF are server-side (Salesforce). Thanks for the brief explanation.
    – Seesh
    Commented Jan 14, 2015 at 6:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .