• westofoxley
  • NEWBIE
  • 10 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 6
    Replies
Hi I have spent around 40 hours trying to write a test class and when I remove one error I get another.  

I have set up a simple APEX class that is an extension for a Visualforce page. The VF page has a commandButton that saves and takes you to a different page called "Congratulations.vfp"

When I save my test I get this error:

Error: Compile Error: Variable does not exist: controller.Account.Joe_Test__c at line 15 column 9

Here is my Code:

APEX CLASS --

public class linkToVFP {
private ApexPages.StandardController controller;
public linkToVFP(ApexPages.StandardController controller) {
this.controller = controller;
}

  public PageReference saveAndCongrat() {
  controller.save(); // This takes care of the details for you.
  PageReference congratsPage = Page.Congratulations;
  congratsPage.setRedirect(true);
  return congratsPage;
}
}


VF Page --

<apex:page standardController="Account" extensions="linkToVFP">
    <apex:form >
        <apex:inputCheckbox value="{!Account.Joe_Test__c}" selected="" />
        <apex:commandButton value="Go To New Page" action="{!saveAndCongrat}"/>
    </apex:form>
</apex:page>

Test --

@isTest
public class linkToVFP_TEST {

    public static testMethod void testMyClass(){
        Account a = new Account(Name = 'Test Account', Joe_Test__c = false);
        insert a;

        PageReference pg = Page.Congratulations;
        Test.setCurrentPage(pg);

        ApexPages.StandardController stdController = new ApexPages.StandardController(a);
        linkToVFP customController = new linkToVFP(stdController);

        system.assertEquals(false, a.Joe_Test__c);
        controller.Account.Joe_Test__c = true;
        PageReference newPage = controller.saveAndCongrat();

        Account newAccount = [Select Id, Joe_Test__c From Account Where Id =: a.Id];
        system.assertEquals(true, a.Joe_Test__c);

        system.assertEquals(Page.Congratulations, newPage);
    }
}

It is probably something simple that I am missing but I havent been working with Apex for long and I have come from a HTML/CSS/PHP background so you might need to dumb it down a little for me.

Thank you.

Hello,

 

I have built a VF page that works fine when I view it from the edit mode "https://c.ap1.visual.force.com/apex/....." 

 

but when I view it as a standalone page "http://xxxxx.force.com/....." it doesn't display any of the output values.  All the css is working fine and the structure....

 

I need to use the page as an iFrame on my Joomla site.

 

This is an example of what I am trying to output:

 

<apex:outputField value="{!ue.Additional_Day_1_Month__c}"/>

 Is there anything I need to do to enable a page to be used within an iFrame on an external server?  

I have enabled the security to web profile etc.

 

Thanks

 

Joe

 

Hi Can someone please help me write a test so I can deploy an APEX class.

 

I had to edit some previous code that someone wrote and I am try to learn APEX and Force and read some articles on testing but don't have a clue on how/ what to test in my code.  Coming from a web designer background you just test it in the browser and  it's all good.

 

public with sharing class EventListsStates {

    private static string prodId;
    private static string noRows;
            
    public EventListsStates() {
        prodId = ApexPages.currentPage().getParameters().get('prodId');
        noRows = ApexPages.currentPage().getParameters().get('noRows');
        noRows = (noRows == null || noRows == '') ? '5' : noRows; 

    }
  
    public Campaign campaign {get ;set ;}

   public list<Campaign> upcommingEventsNSW {get {
        if (upcommingEventsNSW == null) {
            
            upcommingEventsNSW = new List<Campaign>([Select Name,Opportunity_Category__c,Event_Date__c,Venue_Name__c,Event_Month__c,Event_Day__c,Address_Details__c, StartDate, Running_Times__c, Product_Name__c, Location__c, IsActive From Campaign  where Location__c = 'Sydney' and startdate >= today and IsActive = True and Publish_on_the_web__c = true and Product_Name__c = :prodId order by startDate ASC limit :integer.valueOf(noRows)]);
        }
        return upcommingEventsNSW;
    } set;}
    
  
        
}

 Thank you!!

 

Joe

Hi I have spent around 40 hours trying to write a test class and when I remove one error I get another.  

I have set up a simple APEX class that is an extension for a Visualforce page. The VF page has a commandButton that saves and takes you to a different page called "Congratulations.vfp"

When I save my test I get this error:

Error: Compile Error: Variable does not exist: controller.Account.Joe_Test__c at line 15 column 9

Here is my Code:

APEX CLASS --

public class linkToVFP {
private ApexPages.StandardController controller;
public linkToVFP(ApexPages.StandardController controller) {
this.controller = controller;
}

  public PageReference saveAndCongrat() {
  controller.save(); // This takes care of the details for you.
  PageReference congratsPage = Page.Congratulations;
  congratsPage.setRedirect(true);
  return congratsPage;
}
}


VF Page --

<apex:page standardController="Account" extensions="linkToVFP">
    <apex:form >
        <apex:inputCheckbox value="{!Account.Joe_Test__c}" selected="" />
        <apex:commandButton value="Go To New Page" action="{!saveAndCongrat}"/>
    </apex:form>
</apex:page>

Test --

@isTest
public class linkToVFP_TEST {

    public static testMethod void testMyClass(){
        Account a = new Account(Name = 'Test Account', Joe_Test__c = false);
        insert a;

        PageReference pg = Page.Congratulations;
        Test.setCurrentPage(pg);

        ApexPages.StandardController stdController = new ApexPages.StandardController(a);
        linkToVFP customController = new linkToVFP(stdController);

        system.assertEquals(false, a.Joe_Test__c);
        controller.Account.Joe_Test__c = true;
        PageReference newPage = controller.saveAndCongrat();

        Account newAccount = [Select Id, Joe_Test__c From Account Where Id =: a.Id];
        system.assertEquals(true, a.Joe_Test__c);

        system.assertEquals(Page.Congratulations, newPage);
    }
}

It is probably something simple that I am missing but I havent been working with Apex for long and I have come from a HTML/CSS/PHP background so you might need to dumb it down a little for me.

Thank you.
Hi I have spent around 40 hours trying to write a test class and when I remove one error I get another.  

I have set up a simple APEX class that is an extension for a Visualforce page. The VF page has a commandButton that saves and takes you to a different page called "Congratulations.vfp"

When I save my test I get this error:

Error: Compile Error: Variable does not exist: controller.Account.Joe_Test__c at line 15 column 9

Here is my Code:

APEX CLASS --

public class linkToVFP {
private ApexPages.StandardController controller;
public linkToVFP(ApexPages.StandardController controller) {
this.controller = controller;
}

  public PageReference saveAndCongrat() {
  controller.save(); // This takes care of the details for you.
  PageReference congratsPage = Page.Congratulations;
  congratsPage.setRedirect(true);
  return congratsPage;
}
}


VF Page --

<apex:page standardController="Account" extensions="linkToVFP">
    <apex:form >
        <apex:inputCheckbox value="{!Account.Joe_Test__c}" selected="" />
        <apex:commandButton value="Go To New Page" action="{!saveAndCongrat}"/>
    </apex:form>
</apex:page>

Test --

@isTest
public class linkToVFP_TEST {

    public static testMethod void testMyClass(){
        Account a = new Account(Name = 'Test Account', Joe_Test__c = false);
        insert a;

        PageReference pg = Page.Congratulations;
        Test.setCurrentPage(pg);

        ApexPages.StandardController stdController = new ApexPages.StandardController(a);
        linkToVFP customController = new linkToVFP(stdController);

        system.assertEquals(false, a.Joe_Test__c);
        controller.Account.Joe_Test__c = true;
        PageReference newPage = controller.saveAndCongrat();

        Account newAccount = [Select Id, Joe_Test__c From Account Where Id =: a.Id];
        system.assertEquals(true, a.Joe_Test__c);

        system.assertEquals(Page.Congratulations, newPage);
    }
}

It is probably something simple that I am missing but I havent been working with Apex for long and I have come from a HTML/CSS/PHP background so you might need to dumb it down a little for me.

Thank you.

Hello,

 

I have built a VF page that works fine when I view it from the edit mode "https://c.ap1.visual.force.com/apex/....." 

 

but when I view it as a standalone page "http://xxxxx.force.com/....." it doesn't display any of the output values.  All the css is working fine and the structure....

 

I need to use the page as an iFrame on my Joomla site.

 

This is an example of what I am trying to output:

 

<apex:outputField value="{!ue.Additional_Day_1_Month__c}"/>

 Is there anything I need to do to enable a page to be used within an iFrame on an external server?  

I have enabled the security to web profile etc.

 

Thanks

 

Joe