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
ScriptMonkeyScriptMonkey 

Sites permissions with sub-object?

I have a visualforce page that shows a child object of Contact.  I tried refrencing the contact.object__r in a visualforce page, putting it in a apex:repeat command.  This works fine when vieing /apex/VFpage, but on sites it doesn't see the values in the sub-object.

Then I tried a second SOQL statement instead, putting it in a varaible "Objects" then repeating on that.  Again, it works fine in  apex mode, but on the site, it stops working.

 

Now the really confusing part. I made a sub-class and iterated through the objects variable, setting an array of this sub-class, setting values from the objects variable, then used THAT in the Visualforce page and looped through it, and it worked fine, sites and apex both.

 

Any idea what can cause this kind of issue? It's clearly not permissions it's just weird handling in visualforce.

Shiv ShankarShiv Shankar
can you post code once..
ScriptMonkeyScriptMonkey

Making a non-proprietary version of the code.. be posted soon.

ScriptMonkeyScriptMonkey

Ok, Below is the code that's making no sense to me.  I can think of no reason it shouldn't work.

 

Here's the VF page:

<apex:page standardController="Contact" extensions="AppTrackerLanding" showHeader="false" >
<head>
    <apex:stylesheet value="{!$Resource.AppTrackerStyles}"/>
    <style>
        #header { 
            background: url('{!$Resource.AppTrackerHeaderBG}');
            height: 120px;
        }
    </style>
</head>
<body>

<apex:outputText value="{!Contact.OwnerId}" rendered="false"/>

<div id="container">
<apex:include pageName="AppTrackerHeader"/>

<div id="leftSide">
<h1>Student Information</h1>
<p>{!LEFT(Contact.FirstName, 1)}. {!Contact.LastName}</p>
<p>{!Contact.MailingCity},&nbsp;{!Contact.MailingState}</p>
<p>&nbsp;</p>
</div>
<apex:outputPanel rendered="{!NOT(ISNULL(owner))}">
    <div id="rightSide">
        <h1>Admission Contact</h1>
        <p>{!owner.Name}</p>
        <p>{!owner.Phone}</p>
        <p>{!owner.Email}</p>
    </div>
</apex:outputPanel>

<div id="infoContainer">&nbsp;</div>

<apex:pageBlock title="Choose an Application">
    <apex:pageBlockTable value="{!applications}" var="app">
        <apex:column headerValue="View Application Details">
            <apex:outputLink value="{!$Page.AppTracker}?id={!app.id}">View Details</apex:outputLink>
        </apex:column>
        <apex:column headerValue="Program" value="{!app.Possible_Academic_Major__c}"/>
        <apex:column headerValue="Start Term" value="{!app.Start_Term_and_Year__c}"/>
        <apex:column headerValue="Received Date" value="{!app.CreatedDate}"/>       
    </apex:pageBlockTable>
</apex:pageBlock>

<div id="footer"><apex:include pageName="AppTrackerFooter"/></div>

</div> <!-- container -->
</body>
</apex:page>

 and here's the class

 

public with sharing class AppTrackerLanding 
{
    public final Contact contact;
    public User owner {get; set;}
    public Application__c[] applications = new List<Application__c>();
    
    public AppTrackerLanding(ApexPages.StandardController stdController) 
    {
        this.contact = (Contact)stdController.getRecord();

        if(this.contact.OwnerId != null)
        {
            User[] owners = [SELECT Id, Name, Phone, Email FROM User WHERE Id = : this.contact.OwnerId];
            if(owners.size() > 0)
                owner = owners[0];
        }
        this.applications = [SELECT Id,Possible_Academic_Major__c,Start_Term_and_Year__c,
         CreatedDate FROM Application__c 
            WHERE Contact__c = : this.contact.Id];
    }
    
    public Application__c[] getApplications()
    {
    	return applications;
    }
}