0

I got an error in my vf page.

Unknown property 'namespace.boardUtil.boardObject.Name'

Here is the code

<apex:page readOnly="true"
    controller="PDFController"   
    applyHtmlTag="false"    
    sidebar="false"    
    showHeader="false"    
    cache="true"    
    renderAs="advanced_pdf"
    docType="html-5.0">
<head>    
 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />    
 <style type="text/css">
     @page {
     size: A4 landscape; /* Changed to portrait mode by removing 'landscape' */    
     padding-left: 0px;    
     padding-right: 0px;      
     }
     .header {
            text-align: left;
            font-size: 20px; /* Adjust the size as needed */
            font-weight: bold;
            margin-bottom: 5px; /* Space between the header and the underline */
        }
     .sub-header {
            font-size: 15px; /* 25% smaller than the header font size */
            color: black;
            text-align: left;
            margin-top: 5px; /* Adjust spacing between header and sub-header as needed */
        }
        .underline {
            margin-top: 5px;
            height: 5px;
            background-color: green;
            width: 100%;
        }

 </style>    
</head>    
   <div class="header">{!data.Name}</div>
   <div class="sub-header">Folder : {!data.folderName}</div>
   <div class="underline"></div>
    
</apex:page>

controller

public class PDFController {
    private final String recordId;
    public boardUtil.boardObject data { get; set; }

    public PDFController() {
        recordId = ApexPages.currentPage().getParameters().get('id');
        data = boardUtil.getboardDataBasedOnId(recordId);
    }
}

boardUtil

public with sharing class boardUtil {
    public class boardObject {
        public Id boardId;
        public String Name;
        public String folderName;
        public List<ComponentObject> components;

        public boardObject() {
            this.boardId = null;
            this.Name = null;
            components = new List<ComponentObject>();
        }

        public boardObject(Id boardId, String Name, String folderName) {
            this.boardId = boardId;
            this.Name = Name;
            this.folderName = folderName;
            components = new List<ComponentObject>();
        }
    }

    public class ComponentObject {
        public Id componentId;
        public Boolean isImage;
        public String type;
        public String imageUrl;
        public String value;
        public String title;
        public String footer;
        public String Subtitle;
        List<object> breakPoints;

        public ComponentObject() {
            this.componentId = null;
            this.type = '';
            this.isImage = null;
            this.imageUrl = '';
            this.title = '';
            this.footer = '';
            this.Subtitle = '';
            this.breakPoints = new List<object>();
        }

        public ComponentObject(
            Id componentId,
            String type,
            String imageUrl,
            String title,
            String footer,
            String Subtitle,
            List<object> breakPoints
        ) {
            this.componentId = componentId;
            this.type = type;
            this.isImage = type != 'Metric' && type != 'FlexTable';
            this.imageUrl = imageUrl;
            this.title = title;
            this.footer = footer;
            this.Subtitle = Subtitle;
            this.breakPoints = breakPoints;
            this.value = '';
        }

        public Id getClassicComponentId() {
            String id = (string) this.componentId;
            return id.substring(0, id.length() - 3);
        }
    }

    public static boardObject getboardDataBasedOnId(Id recordId) {
       // code
   }
}
2
  • the inner class boardobject variable name needs a {get; private set;}. BTW - Class names should be InitialCap.
    – cropredy
    Mar 2 at 19:05
  • Thanks for the solution. It worked, and I am aware of the class naming convention. Actually, I had to remove starting letters from class and variable name because of company compliance. Mar 2 at 22:37

1 Answer 1

0

Your error is occurring on this VF line:

<div class="header">{!data.Name}</div>

Within your controller, despite the outer variable public boardUtil.boardObject data { get; set; } having a public getter, each variable in type boardutil.boardobject that is referenced by the VF page

  • Name
  • folderName

also needs a getter defined

public with sharing class boardUtil {
public class boardObject {
    public Id boardId;
    public String Name {get; private set;}   <==== add here
    public String folderName {get; private set;} <== add here

As a note to others (and I'm sorry you have to put up with weird company naming conventions), class names (outer and inner) should really use Pascal case to make the code more readable to others in the SFDC community. After all, SFDC Class names are all Pascal case as they derive from Java

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .