You need to sign in to do that
Don't have an account?
Visual Unkown Property
I know im missing something simple but cannot figure out what,
I am trying to have the user select an sObject from a list and getting an error when trying to save VF -- Unknown property 'CustomPdfController.allObjectsList'
VF Code:
<apex:page controller="CustomPdfController" >
<apex:form>
<apex:pageblock>
<apex:outputLabel value="Choose Object: "></apex:outputLabel>
<apex:selectList value="{!allObjectsList}"></apex:selectList>
</apex:pageblock>
</apex:form>
</apex:page>
APEX Code:
public with sharing class CustomPdfController {
public list<SelectOption> allObjectsList(){
list<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();
list<SelectOption> options = new list<SelectOption>();
options.add(new SelectOption('','--SELECT--'));
for(Schema.SObjectType gd1:gd){
options.add(new SelectOption(gd1.getDescribe().getName(),gd1.getDescribe().getName()));
}
options.sort();
return options;
}
}
I am trying to have the user select an sObject from a list and getting an error when trying to save VF -- Unknown property 'CustomPdfController.allObjectsList'
VF Code:
<apex:page controller="CustomPdfController" >
<apex:form>
<apex:pageblock>
<apex:outputLabel value="Choose Object: "></apex:outputLabel>
<apex:selectList value="{!allObjectsList}"></apex:selectList>
</apex:pageblock>
</apex:form>
</apex:page>
APEX Code:
public with sharing class CustomPdfController {
public list<SelectOption> allObjectsList(){
list<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();
list<SelectOption> options = new list<SelectOption>();
options.add(new SelectOption('','--SELECT--'));
for(Schema.SObjectType gd1:gd){
options.add(new SelectOption(gd1.getDescribe().getName(),gd1.getDescribe().getName()));
}
options.sort();
return options;
}
}
Change this: <apex:selectList value="{!allObjectsList}"></apex:selectList>
To this:
<apex:SelectList value="{!val}">
<apex:selectOptions value="{!allObjectsList}">
</apex:selectOptions>
</apex:SelectList>
Add this to your apex code
public String val {get;set;}
Basically, the allObjectsList are the OPTIONS, the value selected will be stored in the variable val which you will add in your Apex code.
As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.
Thanks
All Answers
Change this: <apex:selectList value="{!allObjectsList}"></apex:selectList>
To this:
<apex:SelectList value="{!val}">
<apex:selectOptions value="{!allObjectsList}">
</apex:selectOptions>
</apex:SelectList>
Add this to your apex code
public String val {get;set;}
Basically, the allObjectsList are the OPTIONS, the value selected will be stored in the variable val which you will add in your Apex code.
As a common practice, if your question is answered, please choose 1 best answer.
But you can give every answer a thumb up if that answer is helpful to you.
Thanks
Here you go, just cut and paste the code, since you never declare a variable AllObjectsList, you need to turn the method into a getter method by putting a get in front.
thx
VF Code:
APEX CODE: