Reply
Regular Contributor
Nervosa
Posts: 48
0
Accepted Solution

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.

Super Contributor
sfdcfox
Posts: 4,044
0

Re: Problem with COPIED-EDITED-PASTED code from tutorial.

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.

~ sfdcfox ~


I am a sandwich. That is all.

Regular Contributor
Nervosa
Posts: 48
0

Re: Problem with COPIED-EDITED-PASTED code from tutorial.

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!

Super Contributor
sfdcfox
Posts: 4,044
0

Re: Problem with COPIED-EDITED-PASTED code from tutorial.

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.

~ sfdcfox ~


I am a sandwich. That is all.

Regular Contributor
Nervosa
Posts: 48
0

Re: Problem with COPIED-EDITED-PASTED code from tutorial.

Thank you again :)