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
sukumarsukumar 

Problem with apex and visual force

This is my visual force page

<apex:page standardController="Employee_Info__c" showHeader="false">
         <apex:pageBlock title="Hello {!$User.LastName}!">
            <style>
            .activeTab {background-color: #236FBD; color:white;
            background-image:none}
            .inactiveTab { background-color: lightgrey; color:black;
            background-image:none}
            </style>
            <apex:tabPanel switchType="client" selectedTab="EmployeeInfoTabDetails" id="EmployeeInfoTabPanel" tabClass="activeTab" inactiveTabClass="inactiveTab">
                <apex:tab label="Employee Information" name="EmployeeInfoDetails" id="EmployeeInfoTabDetails">
                    <apex:detail relatedList="false" title="true"/>
                </apex:tab>
    
                <apex:tab label="Personal Information" name="PersoanlInfoDetails" id="PersoanlInfoTabDetails">
                    <apex:detail relatedList="false" title="true"/>
                </apex:tab>
               <apex:tab label="Leaves Information" name="LeavesInfoDetails" id="LeavesInfoTabDetails">
                    <apex:relatedList list="Apply_New_Leave__r"/>
                </apex:tab>
            </apex:tabPanel>
            <apex:form >
                <apex:inputField label="Name" value="{!Employee_Info__c.Name}"/>
                <apex:commandButton action="{!save}" value="Save New Employee Name"/>
            </apex:form>
         </apex:pageBlock>
</apex:page>

This is my controller

/**
 * An apex page controller that exposes the site login functionality
 */
global with sharing class SiteLoginController {
    global String username {get; set;}
    global String password {get; set;}

    global PageReference login() {
        System.debug('Sukumar:::::::::::::::::');
        String startUrl = '/apex/EmployeeInfoTest?id=a0C9000000BaAh8';
       System.debug(startUrl);
        return Site.login(username, password, startUrl);
    }
    
    global SiteLoginController () {}
    
    @IsTest(SeeAllData=true) global static void testSiteLoginController () {
        // Instantiate a new controller with all parameters in the page
        SiteLoginController controller = new SiteLoginController ();
        controller.username = 'test@salesforce.com';
        controller.password = '123456';
                
        System.assertEquals(controller.login(),null);                           
    }    
}

This is my debug log

27.0 APEX_CODE,DEBUG;APEX_PROFILING,INFO;CALLOUT,INFO;DB,INFO;SYSTEM,DEBUG;VALIDATION,INFO;VISUALFORCE,INFO;WORKFLOW,INFO
03:01:22.028 (28412000)|EXECUTION_STARTED
03:01:22.028 (28460000)|CODE_UNIT_STARTED|[EXTERNAL]|06690000002Xyjp|VF: /apex/EmployeeInfoTest
03:01:22.525 (67358000)|CUMULATIVE_LIMIT_USAGE
03:01:22.525|CUMULATIVE_LIMIT_USAGE_END

03:01:22.067 (67394000)|CODE_UNIT_FINISHED|VF: /apex/EmployeeInfoTest
03:01:22.067 (67403000)|EXECUTION_FINISHED

I have Some issues


1)In my debug log it is not showing any System.debug() statements.
2)Is there any problem with CUMULATIVE_LIMIT_USAGE. What is cumulative usage.
3)When I click login button in my login page it is showing me error"Error while loading visual force page".
If i remove
<apex:tab label="Leaves Information" name="LeavesInfoDetails" id="LeavesInfoTabDetails">
                    <apex:relatedList list="Apply_New_Leave__r"/>
                </apex:tab>
in my visualforce page. Employee Test visual force page is displayed correctly.

Can anyone help me with the above issues. If you need more information I will provide.

Best Answer chosen by Admin (Salesforce Developers) 
Avidev9Avidev9
have you given permission to the site user for this Apply_New_Leave__r object ?

All Answers

Neha LundNeha Lund

,

 

I cannot see login button in your VF page

Avidev9Avidev9
Your doesnt seem to be pointing to your login controller ie SiteLoginController.
I cant see a extrension in your page
sukumarsukumar
The button is in login page. This is EmployeeInfoTest visualforce page. When user clicks login button in login page It is navigated to above visualforce page(EmployeeInfoTest). Issue is in this page, So I have posted this page. If you want me to post login visual force page then I will post that VF page also.

Thanks for your reply.

Thanks & Regards,

Sukumar Reddy | Software Programmer
Sukumar.mandem@pbsystems.com
C: +91-9493757230
PB Systems - Results. Delivered?.
sukumarsukumar

If anyone has answer......Please let me know

Avidev9Avidev9
Probably the child relationship name is incorrent "Apply_New_Leave__r".
Go to field detail and check the child relation ship name

should be "Apply_New_Leaves__r"
sukumarsukumar

Thanks for your answer.

 

The visual force page is loading when I try to open with url https://c.ap1.visual.force.com/apex/EmployeeInfoTest?id=a0C9000000BaAh8.

 

But When I use apex/EmployeeInfoTest?id=a0C9000000BaAh8 in my apex class , I am getting error.

Avidev9Avidev9
what is your site URL ?
Avidev9Avidev9

Ok.. you are not generating correct url. It should be relative to your site

it should be something like

 

 startUrl = (Site.getPrefix() == NULL ? '' : Site.getPrefix())+'/EmployeeInfoTest?id=a0C9000000BaAh8');

 

Puja_mfsiPuja_mfsi
Hi,
I think you miss '/' in front of the apex.
You can use ' /apex/EmployeeInfoTest?id=a0C9000000BaAh8 ' in apex class.
sukumarsukumar

But the same url working for me when I remove <apex:tab > tag related to leave information

Puja_mfsiPuja_mfsi

Ok, tell me one thing : Is the site login user  have the access to the "Apply_New_Leave__c" object ?

Avidev9Avidev9
have you given permission to the site user for this Apply_New_Leave__r object ?
This was selected as the best answer
sukumarsukumar

I tried like this also but I am getting same error. I am attaching my new debug log , I have doubt in pagereference in my debug log. Please have look at page reference in debug log. If you know the solution please help me

 

05:08:53.051 (51561000)|CODE_UNIT_STARTED|[EXTERNAL]|SiteLoginController set(password,Abcd1!@#)
05:08:53.051 (51601000)|CODE_UNIT_FINISHED|SiteLoginController set(password,Abcd1!@#)
05:08:53.051 (51613000)|CODE_UNIT_FINISHED|SiteLoginController set(password,Abcd1!@#)
05:08:53.052 (52214000)|CODE_UNIT_STARTED|[EXTERNAL]|01p90000002Huk2|SiteLoginController invoke(login)
05:08:53.052 (52272000)|SYSTEM_MODE_ENTER|false
05:08:53.052 (52313000)|SYSTEM_METHOD_ENTRY|[9]|System.debug(ANY)
05:08:53.052 (52346000)|USER_DEBUG|[9]|DEBUG|Sukumar:::::::::::::::::
05:08:53.052 (52361000)|SYSTEM_METHOD_EXIT|[9]|System.debug(ANY)
05:08:53.052 (52458000)|SYSTEM_METHOD_ENTRY|[12]|system.Site.getPrefix()
05:08:53.052 (52545000)|SYSTEM_METHOD_EXIT|[12]|system.Site.getPrefix()
05:08:53.052 (52564000)|SYSTEM_METHOD_ENTRY|[12]|system.Site.getPrefix()
05:08:53.052 (52594000)|SYSTEM_METHOD_EXIT|[12]|system.Site.getPrefix()
05:08:53.052 (52626000)|SYSTEM_METHOD_ENTRY|[13]|System.debug(ANY)
05:08:53.052 (52649000)|USER_DEBUG|[13]|DEBUG|/EmployerLeave/apex/EmployeeInfoTest?id=a0C9000000BmVFK
05:08:53.052 (52661000)|SYSTEM_METHOD_EXIT|[13]|System.debug(ANY)
05:08:53.052 (52686000)|METHOD_ENTRY|[14]|01p90000002Huk2|SiteLoginController.__sfdc_username()
05:08:53.052 (52735000)|METHOD_EXIT|[14]|01p90000002Huk2|SiteLoginController.__sfdc_username()
05:08:53.052 (52769000)|METHOD_ENTRY|[14]|01p90000002Huk2|SiteLoginController.__sfdc_password()
05:08:53.052 (52792000)|METHOD_EXIT|[14]|01p90000002Huk2|SiteLoginController.__sfdc_password()
05:08:53.052 (52817000)|SYSTEM_METHOD_ENTRY|[14]|system.Site.login(String, String, String)
05:08:53.093 (93962000)|SYSTEM_METHOD_EXIT|[14]|system.Site.login(String, String, String)
05:08:53.093 (93979000)|SYSTEM_MODE_EXIT|false
05:08:53.097 (97768000)|CODE_UNIT_FINISHED|SiteLoginController invoke(login)
05:08:53.098 (98768000)|VF_APEX_CALL|loginButton|{!login}|PageReference:https://suku-developer-edition.ap1.force.com/EmployerLeave/secur/frontdoor.jsp?cshc=0000001eShe0000000igBl&portalId=06090000000DZKU&refURL=https%3A%2F%2Fsuku-developer-edition.ap1.force.com%2FEmployerLeave%2Fsecur%2Ffrontdoor.jsp&retURL=%2FEmployerLeave%2Fapex%2FEmployeeInfoTest%3Fid%3Da0C9000000BmVFK&sid=00D90000000igBl%21AQsAQGiD3DM8Cw4tlIaq21JVdpAOq9tGcT7B7c9YQznEeHKoDAZHGZXdL7Ww4pEDfynpAgqnUmzLFr2Qzk2vmuZeNLgUkAwl&untethered=
05:08:53.238 (101007000)|CUMULATIVE_LIMIT_USAGE
05:08:53.238|LIMIT_USAGE_FOR_NS|(default)|
  Number of SOQL queries: 0 out of 100
  Number of query rows: 0 out of 50000
  Number of SOSL queries: 0 out of 20
  Number of DML statements: 0 out of 150
  Number of DML rows: 0 out of 10000
  Number of code statements: 4 out of 200000
  Maximum heap size: 0 out of 6000000
  Number of callouts: 0 out of 10
  Number of Email Invocations: 0 out of 10
  Number of fields describes: 0 out of 100
  Number of record type describes: 0 out of 100
  Number of child relationships describes: 0 out of 100
  Number of picklist describes: 0 out of 100
  Number of future calls: 0 out of 10

05:08:53.238|CUMULATIVE_LIMIT_USAGE_END

05:08:53.101 (101048000)|CODE_UNIT_FINISHED|VF: /apex/SiteLogin
05:08:53.101 (101060000)|EXECUTION_FINISHED
sukumarsukumar

Issue got solved. Great answer.

 

I have given access to the user to this Apply_New_Leave__C object.

 

Thank you so much for your help.

sukumarsukumar

@puja, Thanks for your answer.

 

Great answer. Issue got solved.