0

This is the error I get with the following controller and visual force page:

Error:

Unknown method 'Module_Test2__CM_Components__cStandardController.renderResponse()' Error is in expression '{!renderResponse}' in page module_test2:cmtracknewcomponents2

Controller

public Object firstMethod() {
    //Timeout in seconds, 120is limit
    Continuation con = new Continuation(120);

    // Set callback method
    con.continuationMethod = 'renderResponse';

    showFilterPanel = false;
    showConflictingPanel = false;
    filter = '';
    // Check if selected metadata is a child object
    isChildMetadata = childToParentMetadata.containsKey(metaDataType);
    // Instantiate and refill items list

    metaDataItemsStatic = new List<MetaDataWrapper>();

    Project__c proj = [SELECT Id, Name, TargetOrgId__c, TargetOrgPassword__c, TargetOrgToken__c, TargetOrgUsername__c
                       FROM Project__c
                       WHERE Id = :changeRequest.Project__c];

    MetadataService.FileProperties[] response = apiService.listMetadataByType(con,metaDataType);

    con.state = response;
    return con;

}

public Object renderResponse(Object state){
    if(state == null){
        return null;
    }

    MetadataService.FileProperties[] filePropertiesStatic = (MetadataService.FileProperties[])state;
    // Get already tracked component per selected metadata type
    Map<String, Integer> fullNameToTrackedComponent = new Map<String, Integer>();
    for (CM_Components__c tracked : [
                Select Full_Name__c
                From CM_Components__c
                Where Included_in__c = : changeRequest.Id
                                       AND Metadata_Type__c = :metaDataType]) {
        fullNameToTrackedComponent.put(tracked.Full_Name__c, 1);
    }

    // Create elements list to display on the page
    if (filePropertiesStatic != null) {
        Integer counter = 0;
        for (MetadataService.FileProperties fileProperty : filePropertiesStatic) {

            // Check if already tracked
            if (fullNameToTrackedComponent.containsKey(fileProperty.fullName)) {
                continue;
            }

            MetaDataWrapper wrap = new MetaDataWrapper(
                counter,
                fileProperty.fullName,
                fileProperty.fileName,
                fileProperty.type_x,
                fileProperty.lastModifiedByName,
                fileProperty.lastModifiedDate,
                isChildMetadata);
            metaDataItemsStatic.add(wrap);

            counter++;
        }
    }

    // Sort items
    metaDataItemsStatic.sort();

    // Check items list size
    if (metaDataItemsStatic.size() > COLLECTION_SIZE_LIMIT) {

        showFilterPanel = true;
        ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Warning, 'Retrieved list was too long to display on the page! Please provide a filter to limit results'));

        while(metaDataItemsStatic.size()>COLLECTION_SIZE_LIMIT){
            metaDataItemsStatic.remove(COLLECTION_SIZE_LIMIT);
        }
    }

    return null;
}

Visualforce Page

 <apex:page standardController="CM_Components__c" extensions="CMTrackNewComponentControllerExt2" action="{!init}" sidebar="false" >

 ..........

<apex:pageBlockSectionItem >
    <apex:outputLabel value="Metadata Type:" />
    <apex:selectList size="1" value="{!MetadataType}" onclick="alertWhenChangingMetadata()">
        <apex:selectOptions value="{!MetadataTypes}"/>
        <apex:actionSupport event="onchange"  action="{!firstMethod}" oncomplete="loadItemsTable()" reRender="itemsTable,msgs,filterPanel" />
    </apex:selectList>
</apex:pageBlockSectionItem>

.............................

<!-- Retrieved components table -->
<apex:pageBlockSection id="itemsTable" title="Components Table" collapsible="false" columns="1">

</apex:pageBlockSection>

Why am I getting this error?

  • Please post the full code of your controller extension. WIthout it, we can't help. – DavidSchach Jan 25 '18 at 18:16
0

At first glance, the error is saying that it is looking for a method called renderResponse() that takes zero parameters. You have renderResponse as a method that takes a parameter.

You'll need to find a workaround that will let you use a method without any parameters passed to it.

Also, the error message says that you're calling renderResponse from your VF page OR through your continuation... and you'll need extra code to allow the page to pass a parameter to that method, though over the years, it's become more common for people to avoid doing that and just to have non-parametered methods unless you're using a static method with appropriate @ modifiers.

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.