You need to sign in to do that
Don't have an account?

Apex class not running from site visualforce page
Hello All,
This issue is really bugging me.
I have a visualforce page which is enabled in the force.com site and I have changed the permission set for guest profile to create,edit etc my custom obejct but still I am not seeing the controller class being run from visualforce page.
My visualforce page is
<apex:page sidebar="false" showHeader="true" standardStylesheets="false" standardController="Main_questionaire__c" extensions="QuestionnaireFieldsSite" recordSetVar="sitem" id="thePages" >
<apex:form id="templateForm">
<br></br>
<apex:actionFunction name="sectionStatusJS" action="{!sectionStatus}" reRender="buttonPanel"/>
<p style="text-align:center;font-size:18px">Assessment</p>
<apex:outputPanel id="buttonPanel">
<script>
window.onload=function()
{
sectionStatusJS();
setmyFlag(true);
};
</script>
</apex:outputPanel>
<apex:outputPanel rendered="{!myFlag}">
<apex:pageBlock >
<apex:pageBlockSection id="sectionBlock" title="Sections" columns="4">
<apex:repeat value="{!sectionsStatusLists}" var="section">
<apex:commandButton value=" {!section.Section_Template__r.Section_label__c}" style="text-align:center;">
<apex:param name="sectionId" value="{!section.Section_Template__r.id}"/>
<apex:param name="doRerender" value="true" assignTo="{!doRerender}"/>
</apex:commandButton>
</apex:repeat>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:outputPanel>
</apex:form>
</apex:page>
Apex class THIS CLASS'S IS NEVER CALLED.I SAW THE DEBUG IT DOESNT GET CALLED AT ALL ,NOT EVEN THE CONSTRUCTORS DEBUG STATEMENT
public with sharing class QuestionnaireFieldsSite
{
public List<Section_Template__c > sectionsLists{ get; set; }
public List<Main_questionaire__c> templateLists { get; set; }
public List<SectionStatus__c > sectionsStatusLists{ get; set; }
static integer ltoggle=0;
public Transient Boolean doRerender;
public Boolean getdoRerender(){return doRerender;}
public Boolean myFlag{get; set;}
public void setmyFlag(Boolean flags)
{this.myFlag=flags;}
public void setdoRerender(Boolean doRerender)
{
this.doRerender = doRerender;
System.debug('doRerender should be set here to true: doRerender = '+this.doRerender);
}
public QuestionnaireFieldsSite(ApexPages.StandardSetController controller) {
refreshPagePart=false; System.debug('----------initialized in sectionstatus'+myFlag);
}
public QuestionnaireFieldsSite(){System.debug('-2---------initialized in sectionstatus'+myFlag);}
public void
{myFlag=false;
theToggleVal =false;System.debug('----------initialized in sectionstatus'+myFlag);
if (!myFlag)
{
SectionStatus__c[] StatusLists=new SectionStatus__c[]{};
accountId=System.currentPageReference().getParameters().get('accId');
templateLists = [Select Id, Name from Main_questionaire__c limit 1];
if(templateLists!=NULL && templateLists.size()>=1)
{
templateName = templateLists.get(0).Name;
sectionsLists = [Select Id, Name,status__c,Section_label__c,Order_No__c from Section_Template__c where Questionnaire_Section__c=:templateLists.get(0).Id order by Order_No__c];
SectionStatus__c[] userSectionStatus=[Select id,Section_Template__c,Status__c,User__c,Account_to_SectionStatus__c from SectionStatus__c where Account_to_SectionStatus__c= :accountId] ;
if((userSectionStatus==null)||(userSectionStatus.size()==0))
{
System.debug('~~~~~~~~~~~~~COMES IN SECTION STATUS');
for(Section_Template__c res: sectionsLists )
{
SectionStatus__c stat=new SectionStatus__c();
stat.User__c=UserInfo.getUserId();
System.debug('~~~~~~~~~~~~~default controller------'+stat);
StatusLists.add(stat);
}
try
{
upsert StatusLists;
}
catch(DmlException e){System.debug('~~~~~~~~~~~~~EXCEPTION --'+e);}
}
}
}
sectionsStatusLists=[Select id,Section_Template__c,Section_Template__r.id,Section_Template__r.Section_Label__c from SectionStatus__c where Section_Template__c!=null ] ;
} myFlag=true;}
}
Please help.
Ya I tried , it works there the controller class constructor and action method from visualforce gets called if I login to my org but when I do through the site the controller class constructor or the action method doesnt get called at all.
So I dont know the issue,is it that the action method or javascript doesnt work from force.com site(which should be)?
Thanks
<apex:page sidebar="false" showHeader="true" standardStylesheets="false" controller="QuestionnaireFieldsSite" id="thePages" >
Just make sure to set up any record sets etc you need within your controller class.
Ram
Hi,
You can also check debug logs in the context of site user.
Follow this link and debug in the context of site user.
Thanks,
Devendra
Thanks for the recommendations ,I tried changing the controller to be just controller not standard but it doesnt work.
My issue is it doesnt give any errors and it doesnt even call contructor,I had fixed all the authorization issues and if I login through salesforce everything is fine all code works.
So I was wondering if there is any limitation on sites vf page like you cannot have action function or something else.
Thanks
Ram
Hmm .
Yes the page shows up on my site but it doesnt call my contructor or even the action="{!sectionStatus} method but it does call my get methods so I couldnt understand what is the issue.I am trying to debug the third option on the link mentioned by you guys so that I can find what is the issue.
Thanks again
So I removed my action function and made everything as getter and setter methods on my vf page and now it works.Its wierd not the solution that I was looking for but it works now.
Thanks guys for helping me out.
While copying and editing I must have missed the name in controller but it is the same function which I called from my vf page. Dont know how and why removing it helped but it works.
thanks
I am also facing same issue and did not find any solution yet. I have created a custom link in account object and calling community visualforce page. Controller is not calling at all not even construtor. Controller contains page reference method and calling the same method from page action attribute.
If I call same method with out community URL it works fine. Could you please any one help me if you find any solution.
Thanks,
Raghav