You need to sign in to do that
Don't have an account?
List from my Controller not visible in my Page!!
I am new to this environment.
Here is my controller
public with sharing class MyController { public ApexPages.StandardSetController setCon { get { if(setCon == null) { setCon = new ApexPages.StandardSetController(Database.getQueryLocator([Select m.Start_Time__c, m.Name__c, m.Name From My_Campaign__c m])); } return setCon; } set; } public String getMyName() { My_Campaign__c mc = [Select m.Name From My_Campaign__c m Where Type__c = 'SALE']; return mc.name; } public Integer getMyCount() { Integer count = getMyCampaigns().size(); return count; } public List<My_Campaign__c> getMyCampaigns() { List<My_Campaign__c> campaigns = (List<My_Campaign__c>) setCon.getRecords(); String output = ' '; for (My_Campaign__c mc : campaigns) { output += ' ' + mc.Name__c + ' '; } System.debug('\n\n>>>>> Output : \n' + output); return campaigns; }}
Here is my visualForce markup
<apex:page title="My Campaign Page {!$User.FirstName}" showHeader="false" controller="MyController">This is your new page for the {!name} controller. <br /> This is your new page for the [{!$User.userName}] controller. <br /> This is MyUser {!myUser} controller. <br /> This is the count {!myCount} controller. <br /> This is the name [{!myName}] <br /> <apex:pageBlock title="Campaigns"> <apex:pageBlockTable value="{!myCampaigns}" var="c"> <apex:column value="{!c.Start_Time__c}" /> <apex:column value="{!c.Name__c}" /> <apex:column value="{!c.Name}" /> </apex:pageBlockTable> </apex:pageBlock></apex:page>
Everything prints (including myName, myCount) except the "pageBlockTable"!!, so this might not be a security issue.
It must be a permissions issue. I created a new user profile and went through the whole process
of assigning it to the customer portal and made sure the custom objects got the right check boxes
and everything worked fine!!
I am still getting used to force.com security and nuances associated with it.
All Answers
formatted version:
public with sharing class MyController {
public ApexPages.StandardSetController setCon { get { if(setCon == null) { setCon = new ApexPages.StandardSetController(Database.getQueryLocator([Select m.Start_Time__c, m.Name__c, m.Name From My_Campaign__c m])); } return setCon; } set; } public String getMyName() { My_Campaign__c mc = [Select m.Name From My_Campaign__c m Where Type__c = 'SALE']; return mc.name; } public Integer getMyCount() { Integer count = getMyCampaigns().size(); return count; } public List<My_Campaign__c> getMyCampaigns() { List<My_Campaign__c> campaigns = (List<My_Campaign__c>) setCon.getRecords(); String output = ' '; for (My_Campaign__c mc : campaigns) { output += ' ' + mc.Name__c + ' '; } System.debug('\n\n>>>>> Output : \n' + output); return campaigns; } }
<apex:page title="My Campaign Page {!$User.FirstName}" showHeader="false" controller="MyController"> This is your new page for the {!name} controller. <br /> This is your new page for the [{!$User.userName}] controller. <br /> This is MyUser {!myUser} controller. <br /> This is the count {!myCount} controller. <br /> This is the name [{!myName}] <br /> <apex:pageBlock title="Campaigns"> <apex:pageBlockTable value="{!myCampaigns}" var="c"> <apex:column value="{!c.Start_Time__c}" /> <apex:column value="{!c.Name__c}" /> <apex:column value="{!c.Name}" /> </apex:pageBlockTable> </apex:pageBlock> </apex:page>
What does the {!myCount} render as on the page?
Also, what do you see in your debug output - i.e. does it look like the list is populated but not rendered, or is the list empty?
It renders the number of records - the size of the list.
The Debug output has the expected result as well.
It is only the Visualforce page that is not rendering the List, it is however
rendering the method which returns only one field of the custom
object, so I think it is not a security issue.
It must be a permissions issue. I created a new user profile and went through the whole process
of assigning it to the customer portal and made sure the custom objects got the right check boxes
and everything worked fine!!
I am still getting used to force.com security and nuances associated with it.