+ Start a Discussion
IsmaelIsmael 

Problem with Custom Controller within a Managed Package

Good morning,

I'm developing a Visualforce page to be part of a managed package using the 'WFM' prefix/namespace. This package includes a custom object called 'Round' that I want to use within a Visualforce page. For this purpose, I included the following code in the Page:

 <apex:inputField id="roundName" value="{!WFM__Round__c.Name}"/>

I also included the following code in the Controller:

   public WFM__Round__c getWFM__Round__c() {
      if(round == null) round = new WFM__Round__c();
      return round;
   }

This generates the following error:

ErrorError: Compile Error: Invalid identifier: getWFM__Round__c at line 11 column 25

Any idea?

Many thanks in advance for your help.

-Ismael
dchasmandchasman
Apex code (and the rest of Salesforce metadata for that matter) does not allow the use of double underscores in the names of things - same is true for a few other values like __c. The double underscore is reserved for the delimiter between namespace and name.
IsmaelIsmael
Doug,

Thanks for the answer. Does it mean that Visualforce does not support the use of objects that are part of managed packages?

-Ismael
dchasmandchasman
It does not mean that at all - it just means that you cannot use __ in your method name in this specific example:

Code:
public WFM__Round__c getWFM__Round__c() {
if(round == null) round = new WFM__Round__c();
return round;
}

just change the method name to something that does not use __ in the name, e.g.

Code:
public WFM__Round__c getRound() {
if(round == null) round = new WFM__Round__c();
return round;
}

 


IsmaelIsmael
I tried that. Now the error becomes:

    Error: Unknown property 'newRoundController.WFM__Round__c'    
    Create Apex method 'WFM__newRoundController.getWFM__Round__c'

For reference purposes, here is the code used in the Page:

<apex:inputField id="roundName" value="{!WFM__Round__c.Name}"/>

Am I missing something?

Thanks again for your help.

-Ismael
IsmaelIsmael
Doug,

We found a way to make it work, using your code and the following code in the page:

<apex:inputField id="roundName" value="{!round.name}"/>

Thanks a lot for your help!

-Ismael
PranavLPranavL

Can you please share what the code was as I cannot see it in the above posts.

 

Thanks!