1

I have a fairly simple code where I'm querying an object, getting the records and mapping them to a list in order to show them in a VF page. The page is still unfinished but I'm wondering what is happening since I'm getting invisible cells.

This is the controller extension:

public with sharing class newQuotedProfileControllerExtension {

    /* Getters and Setters */

    public Quoted_Profile__c a {get;set;}
    public Apexpages.StandardController std;
    public List<Profile_Element__c> pElements {get;set;}

    /* Main class invoked on page load */
    
    public newQuotedProfileControllerExtension(ApexPages.StandardController stdcontroller) {
        a = (Quoted_Profile__c)stdcontroller.getRecord();
        std = stdcontroller;
    
        pElements = New List<Profile_Element__c>();
        processElements();
        system.debug('Profile Elements: ' + pElements);
    }

    public List<SelectOption> getProfileOptions(){

        //Get all active Master Profile records
        List<Master_Profile__c> results = [SELECT Id, Name, Country__c, Profile_Type__c, Recruitment_Recommended_Margin__c, Payroll_Recommended_Margin__c, Active__c
                                           FROM Master_Profile__c
                                           WHERE Active__c = true];

        List<SelectOption> options = New List<SelectOption>();
        //Add default value in case there is no returned records
        options.add(new SelectOption('','-None-'));
        for(Master_Profile__c m : results){
            options.add(new SelectOption(m.id, m.Name));
        }

        return options;
    }

    public void processElements(){

        //Get all Master Elements applicable to the Quoted Profile
        List<Master_Element__c> results = [SELECT ID, Name, Active__c, Element_Type__c, Max_Percentage__c
                                           FROM Master_Element__c
                                           WHERE Active__c = true];

        //Map Master Elements to Profile Elements
        for (Master_Element__c m : results){
            Profile_Element__c p = new Profile_Element__c (
                Element_Type__c = m.Element_Type__c,
                Master_Element__c = m.id,
                Max_Percentage__c = m.Max_Percentage__c,
                Quoted_Profile__c = a.id
            );
            pElements.add(p);
        }
    }


}

and this is the VF code:

<apex:page standardController="Quoted_Profile__c" extensions="newQuotedProfileControllerExtension" lightningStylesheets="true" standardStylesheets="true" showHeader="true" sidebar="false">
<apex:slds /> 
<html>
  <head>
    <style type="text/css">
      .tableHeader {
        text-align: center !important;
        background-color: rgb(29, 144, 221) !important;
        color: white !important;
      }
      .tableRow {
        text-align: center !important;
        background-color: white !important;
        color: black !important;
      }
    </style>
  </head>
  <body>
    <apex:form >
      <apex:pageBlock title="New Profile" id="pageBlock">

      <!-- * * * * * * * * * * Quoted Profile Layout * * * * * * * * * * -->
        <!-- Information Section -->
        <apex:outputPanel id="infoPanel">
          <apex:actionRegion >
            <apex:pageBlockSection title="Information" columns="2">
              <apex:inputField value="{!Quoted_Profile__c.Name}"></apex:inputField>
              <apex:outputField value="{!Quoted_Profile__c.Quote__c}"></apex:outputField>
              <apex:selectList value="{!Quoted_Profile__c.Profile__c}" multiselect="false" size="1" id="profileValues" title="Master Profile">
                <apex:selectOptions value="{!ProfileOptions}"/>
              </apex:selectList>
              <apex:outputField value="{!Quoted_Profile__c.Approval_Status__c}"></apex:outputField>
            </apex:pageBlockSection>
          </apex:actionRegion>
        </apex:outputPanel>
        <!-- Totals Section -->
        <apex:outputPanel id="totalsPanel">
          <apex:actionRegion >
            <apex:pageBlockSection title="Totals" columns="3">
              <apex:inputField value="{!Quoted_Profile__c.Workers_Recruited_by_JT__c}"></apex:inputField>
              <apex:inputField value="{!Quoted_Profile__c.Profile_Workers__c}"></apex:inputField>
              <apex:inputField value="{!Quoted_Profile__c.Payroll_Workers__c}"></apex:inputField>
            </apex:pageBlockSection>
          </apex:actionRegion>
        </apex:outputPanel>
        <!-- Totals Section -->
        <apex:outputPanel id="informativeElementsPanel">
          <apex:actionRegion >
            <apex:pageBlockSection title="Totals" columns="2">
              <apex:inputField value="{!Quoted_Profile__c.Medical_Check_ups__c}"></apex:inputField>
              <apex:inputField value="{!Quoted_Profile__c.IPEs__c}"></apex:inputField>
            </apex:pageBlockSection>
          </apex:actionRegion>
        </apex:outputPanel>
        <!-- Margins Section -->
        <apex:outputPanel id="marginsPanel">
          <apex:actionRegion >
            <apex:pageBlockSection title="Profile Informative Elements" columns="2">
              <apex:outputField value="{!Quoted_Profile__c.Recruitment_Recommended_Margin__c}"></apex:outputField>
              <apex:outputField value="{!Quoted_Profile__c.Payroll_Recommended_Margin__c}"></apex:outputField>
              <apex:outputField value="{!Quoted_Profile__c.Recruitment_Effective_Margin__c}"></apex:outputField>
              <apex:outputField value="{!Quoted_Profile__c.Payroll_Effective_Margin__c}"></apex:outputField>
            </apex:pageBlockSection>
          </apex:actionRegion>
        </apex:outputPanel>
        <!-- Discounts / Increasing Elements Section -->
        <apex:outputPanel id="discountIncreasingElementsPanel">
          <apex:actionRegion >
            <apex:pageBlockSection title="Discounts / Increasing Elements" columns="2">
              <apex:outputField value="{!Quoted_Profile__c.Decreasing_Total__c}"></apex:outputField>
              <apex:outputField value="{!Quoted_Profile__c.Increasing_Total__c}"></apex:outputField>
              <apex:inputField value="{!Quoted_Profile__c.Recruitment_Special_Additional_Discount__c}"></apex:inputField>
              <apex:inputField value="{!Quoted_Profile__c.Payroll_Special_Additional_Discount__c}"></apex:inputField>
            </apex:pageBlockSection>
          </apex:actionRegion>
        </apex:outputPanel>
      <!-- * * * * * * * * * * End of Quoted Profile Layout * * * * * * * * * * -->

      <!-- * * * * * * * * * * Profile Elements Layout * * * * * * * * * * -->
      <apex:outputPanel id="profileElementsPanel">
          <apex:pageBlockTable value="{!pElements}" var="e" title="Profile Elements" id="profileElementsTable">
            <apex:column headerValue="Master Element">
              <outputField value="{!e.Master_Element__c}"></outputField>
            </apex:column>
            <apex:column headerValue="Element Type">
              <outputField value="{!e.Element_Type__c}"></outputField>
            </apex:column>
            <apex:column headerValue="Max Percentage">
              <outputField value="{!e.Max_Percentage__c}"></outputField>
            </apex:column>
            <apex:column headerValue="Desired Percentage">
              <inputField value="{!e.Percentage__c}"></inputField>
            </apex:column>
            <apex:column headerValue="Apply">
              <inputField value="{!e.Apply__c}"></inputField>
            </apex:column>
          </apex:pageBlockTable>
       </apex:outputPanel>



      <!-- * * * * * * * * * * End of Profile Elements Layout * * * * * * * * * * -->

      </apex:pageBlock>
    </apex:form>
  </body>
</html>

</apex:page>

These are my results so far:

  • This is the current VF output: VF output
  • Checked the Developer log and I'm getting data returned for pElements which is the List being looped in the pageBlockTable
  • Inspected the table in the browser and I'm seeing the following (notice that the size of the cell is 0x0 and on the elements rendered by the browser, the ouputField has a value of 0.50: enter image description here

I don't know what I'm missing here. I want to add more buttons inside the table and I can't because I want to make sure it's rendering data properly.

Thanks

1

Minor problem, you need to use apex:outputText instead of outputText.

Due to this, the Visualforce engine is unable to draw the cell with outputField as it is not a valid apex component.

<outputField value="{!e.Master_Element__c}"></outputField>

should be:

<apex:outputField value="{!e.Master_Element__c}"></apex:outputField>

This is equivalent to missing semicolon in apex, unfortunately doesn't gives us the error (reminds of the meme, hide and seek champion ; since 1958).

1

Visualforce's field components respect the field level security (FLS) defined in the profile/permission sets. Most likely you don't have view/edit rights set for the fields that are not appearing. (And/or the object level permissions.)

1
  • Hi @Keith C, I can see the records in the regular UI and I checked that I have all the permissions necessary to read the records. Nov 22 '20 at 17:27

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.