function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Abhishek KedariAbhishek Kedari 

Displaying class field values on visualforce page

I have a class which contains list of custom class objects (list of different class object which I created). Now I want to show this list of objects on visualforce page and I need access to every field of this list of class object. How I can do that ?

Please find below code snippest for better understanding of the problem. 

Apex Classes :
1)  ShipmentHistoryRecord   (Class whose data I want to show on visualforce page)
public with sharing class ShipmentHistoryRecord {
     public String businessContact;	         
     public String techContact;	        
     List<Product> products;	         	     
    // Constructor
    public ShipmentHistoryRecord(String businessContact, String techContact,List<Product> products) {
	            this.businessContact = businessContact;
	            this.techContact = techContact;
	            this.products = products.clone();
       public class Product {
	            public String productName;
	            public String version;

2) ShipmentHistory
public with sharing class ShipmentHistory {



   public List<ShipmentHistoryRecord> shipmentHistoryTest{get;set;}



    public ShipmentHistory(ApexPages.StandardController controller) {


         shipmentHistoryTest = new List<ShipmentHistoryRecord>();

         getShipmentHistory(<"sending some JSON string which is valid and works for below code">);





     public void getShipmentHistory(String jsonStr) {


          // Parse entire JSON response.

          JSONParser parser = JSON.createParser(jsonStr);

          while (parser.nextToken() != null) {

            if (parser.getCurrentToken() == JSONToken.START_ARRAY) {

                while (parser.nextToken() != null) {

                    if (parser.getCurrentToken() == JSONToken.START_OBJECT) {

                        ShipmentHistoryRecord history =(ShipmentHistoryRecord)parser.readValueAs(ShipmentHistoryRecord.class);

                        String s = JSON.serialize(history);

                        system.debug('JSONParser:getShipmentHistory: Shipment History : ' + s);








3) Visualforce page code sample :
<apex:page standardController="Opportunity" extensions="ShipmentHistory">
<apex:repeat value="{!shipmentHistoryTest}" var="history"> 

     <apex:outputText title="Product" value="{!history.businessContact}"></apex:outputText>


Solutions I tried :
1) Define multiple extensions lik1 <apex:page standardController="Opportunity"extensions="ShipmentHistory,ShippingHistoryRecord">
     Issue got: [Error] Error: Unknown property 'ShipmentHistoryRecord.'
     but if I print 'history' instead of 'history.businessContact', it prints the whole record correctly

2) Creatin inner classes, of ShippingHistoryRecord and Product
    Issue I got: Save error: Initial term of field expression must be a concrete SObject:  LIST<LIST<String>>
IMP Note:
There is no object created like ShipmentHistory or ShippingHistoryRecord (So I am not storing any of these values), these re just classes used to hold the values temporaly.