0

I have tried retrieving values of data from the controller and map them to the VF page. But, the mapped data is not being visible on the VF page, whereas in the debug of the controller it is visible.

Below is my controller:

public with sharing class QuotePDFController {
public quote__c quotesRecords {get;set;}
public QuotePDFcontroller(){
    quotesRecords = new Quote__c();
    //Id recordId = standardController.getId();
    Quote__c quotesRecords = [select Id,Name,Lab_Request__c, (SELECT Id, Name, Product__r.Name FROM Quote_Line_Items__r) FROM Quote__c where Id =: ApexPages.currentPage().getParameters().get('id') Limit 1];
    system.debug('quote isssss '+quotesRecords.Name);
}}

My VF page code is:

<apex:page  controller="QuotePDFController"
           readOnly="true"      
           applyHtmlTag="false"     
           sidebar="false"     
           showHeader="false"     
           cache="true"     
           renderAs="advanced_pdf">  

<html>
        <head>
            <style type="text/css">
                @page {
                <!--size: letter;
                margin: 15mm;-->
                    @top-center {
                     content: "";
                    }
                    @bottom-right {
                        content: "Page " counter(page) " of " counter(pages);
                    }
                    @bottom-left {
                        content: "THIS IS A COMPUTER GENERATED ORDER AND NO SIGNATURE REQUIRED"
                    }
                }
                
                .page-break {
                    display: block;
                    page-break-after: always;
                }
                
                body {
                    font-family: OpenSans-Regular;
                }
   
                table{
                    border: 1px;
                }
            </style>
        </head>
        <body>            
                        <table border="1" align="center" style="border-collapse: collapse;" padding="10px">
                        <tr style="padding-top: 5px;padding-right: 3px;padding-bottom: 5px;padding-left: 3px;">
                            <th> {!quotesRecords.Name} </th>
                        </tr>            
                    </table>
        </body>
    </html>
</apex:page>
2
  • 1
    Inside Constructor, A local variable is declared with the same name as an instance variable. Instead, directly populate the instance variable. It will fix your issue. – H R Dec 30 '20 at 14:22
  • Please refer to this doc to know more about Instance variables and Local Variables with the Same Name. chortle.ccsu.edu/java5/Notes/chap34A/ch34A_11.html – H R Dec 30 '20 at 14:24
1

Inside Constructor, A local variable is declared with the same name as an instance variable. Instead, directly populate the instance variable. It fixed my issue.

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.