2

So I am trying to create a custom button to open a visualforce page but I'm having issues calling the apex class.

I'm getting the following error: common.apex.runtime.bytecode.BytecodeApexObjectType cannot be cast to common.apex.runtime.impl.ApexType

Here is my Class:

public class APM_OpenChart {
    private ApexPages.StandardController controller;    
    public APM_OpenChart(ApexPages.StandardController stdController) {
        controller = stdController;
    }

    public PageReference openChart()
    {
        return Page.chart1;
    }    
}

Here is the visualforce page string to extend to that class:

<apex:page standardController="APM__c" extensions="APM_OpenChart" id="pgid" recordSetVar="apps">
    <apex:form>
        <apex:pageblock mode="edit" id="yearPageBlock">
            <apex:pageBlockButtons>
                <apex:commandButton action="{!openChart}" value="OpenChart"/>
            </apex:pageBlockButtons>

Am I calling this apex class incorrectly? The error is happening on line 0 of my VF page.

3

It's because you're passing in a recordsetvar

Try changing your controller to:

public class APM_OpenChart {
private ApexPages.StandardSetController controller;    
public APM_OpenChart(ApexPages.StandardSetController controller) {
    this.controller = controller;
}

public PageReference openChart()
{
    return Page.chart1;
}    
  • we posted at the exact same time! Perfect answer – tjcinnamon Jan 25 '16 at 20:18
2

I guess I needed to use a StandardSetController. The blank constructor worked.

public class APM_OpenChart {

    public APM_OpenChart(ApexPages.StandardSetController stdController) {

    }

    public PageReference openChart()
    {
        return Page.chart1;
    }    
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.