function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SBKSBK 

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.
 
I know I am doing something stupid, but not sure what.
 
How do you go about debugging these kind of problems?
 
Thanks  a bunch!! 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
SBKSBK

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

SBKSBK

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>

 

bob_buzzardbob_buzzard

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? 

SBKSBK

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.

 

 

SBKSBK

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. 

This was selected as the best answer