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
NervosaNervosa 

Problem with COPIED-EDITED-PASTED code from tutorial.

Hello!

 

I did the following - copied and edited APEX class from tutorial so it looks like this:

 

public class FullFunctionality {

    DisplayMerchandise[] products;

    public class DisplayMerchandise {
        public Item__c merchandise { get; set; }
        public DisplayMerchandise(Item__c item) {
            this.merchandise = item;
        }
    }

    public DisplayMerchandise[] getProducts() {
        if (products == null) {
            products = new DisplayMerchandise[]{};
            for (Item__c item : 
                [SELECT id, name, item_price__c 
                 FROM Item__c ]) {
               products.add(new DisplayMerchandise(item));
             }
         }
     return products;      
    }
}

 My VF page uses this classlike this -

 

<apex:page standardStylesheets="false" showHeader="false" sidebar="false" Controller="FullFunctionality">
<apex:stylesheet value="{!URLFOR($Resource.Styles, 'styles.css')}"/>

<apex:dataTable value="{!products}" var="pitem" rowClasses="odd,even" align="center">
    <apex:column >
        <apex:form style="width:50px">
            <apex:inputCheckbox />
        </apex:form>
    </apex:column>
    <apex:column headerValue="Item name" style="text-align:left">
        <apex:outputText value="{!pitem.name}"/>
    </apex:column>
    <apex:column headerValue="Price" >
        <apex:outputText value="{!pitem.Item_Price__c}"/>
    </apex:column>

</apex:dataTable>
</apex:page>

 But I get an error message:"Error: Unknown property 'FullFunctionality.DisplayMerchandise.name'"

 

Please help me to get rid of it.

Thanx in advance.

Best Answer chosen by Admin (Salesforce Developers) 
sfdcfoxsfdcfox

Fixed:

 

    <apex:column headerValue="Item name" style="text-align:left">
        <apex:outputText value="{!pitem.merchandise.name}"/>
    </apex:column>
    <apex:column headerValue="Price" >
        <apex:outputText value="{!pitem.merchandise.Item_Price__c}"/>
    </apex:column>

Assuming all fields are otherwise correct.

All Answers

sfdcfoxsfdcfox

Fixed:

 

    <apex:column headerValue="Item name" style="text-align:left">
        <apex:outputText value="{!pitem.merchandise.name}"/>
    </apex:column>
    <apex:column headerValue="Price" >
        <apex:outputText value="{!pitem.merchandise.Item_Price__c}"/>
    </apex:column>

Assuming all fields are otherwise correct.

This was selected as the best answer
NervosaNervosa

Thank you - it works!

Not to create another thread i also want to ask - how can i display record's creation date? I can't find it amond standard fields!

sfdcfoxsfdcfox

It is in there, but doesn't appear that way in the normal list.

 

* Modify the query to include CreatedDate.

* Modify the page to display CreatedDate.

NervosaNervosa

Thank you again :)