You need to sign in to do that
Don't have an account?
including VisualforcePage based on the name defined in a custom setting variable
Hi all,
I am developing a managed package with VisualforcePages containing a lot of Javascript code.
This Code contains Function-calls to a Javascript "Class" Customizations.
When I deploy a package to an end customer the packaged VisualforcePages are read-only. Therefore I need a way to provide the possibility to our end customers that they can create a new VisualforcePage where they define a Javascript Object Customizations which is being called by our packaged code.
The part where I want to include the Custom VisualforcePage
The intention here is, that the VisualforcePage is only imported into the code if the Page exists
<apex:outputPanel rendered="{!!ISBLANK($Setup.cnx__Settings__c.cnx__Custom_Pagename__c)}"> // This code is only executed if the custom pagename is defined <apex:include pageName="{!JSENCODE($Setup.cnx__Settings__c.cnx__Custom_Pagename__c)}" /> <script type="text/javascript"> // init customer configuration if(typeof Customizations === 'function') { var custom = new Customizations(); } </script> </apex:outputPanel>
The custom VisualForce Page not part of the managed package
This VisualforcePage is created by the Customer and is not part of the managed package and will be included with the code-listing above if the page exists
<apex:page > <script type="text/javascript"> function Customizations() { this.GetSettings = function(data) { //manipulate the data here return data; } this.ContactLookup = function(data) { //create a ContactLookup here return data; } // ... } </script> </apex:page>
This code works flawlessly if the ...Custom_Pagename__c Custom Setting is defined and contains a value. The problem arises if the custom setting is set to ''.
I always get the following error:
The name '' can only contain underscores and alphanumeric characters. It must begin with a letter and be unique, and must not include spaces, end with an underscore, or contain two consecutive underscores.
In my understanding the code between <apex:outputPanel></apex:outputPanel> should only be evaluated if the rerended attribute is TRUE. correct?
Does anyone have a suggestion how to solve this issue?
Thanks
Lorenz
Have you tried the following?
Have a blank/placeholder VF page (maybe with an error message) and display it when cnx__Custom_Pagename__c is empty.
Thanks.
All Answers
Have you tried the following?
Have a blank/placeholder VF page (maybe with an error message) and display it when cnx__Custom_Pagename__c is empty.
Thanks.
Yes, this works!
Thanks a lot!
Lorenz