You need to sign in to do that
Don't have an account?
aneelu vaddadi
I created an apex class and VF page in Eclipse, there are no errors when I want to display VF page I am unable to see th result..can any one help me
apex:page controller="StoreFrontController_AC" tabstyle="Merchandise__c" >
<apex:pageBlock title="our products">
<apex:pageBlockSection columns="1">
<apex:pageBlockTable value="{!products}" var="pitem">
<apex:column headerValue="Product">
<apex:outputText value="{!pitem.Name}"/>
</apex:column>
<apex:column headerValue="Description">
<apex:outputText value="{!Description__c}"/>
</apex:column>
<apex:column headerValue="Price" style="text-align: right;">
<apex:outputText value="{0,number,currency}">
<apex:param value="{!pitem.Price}"/>
</apex:outputText>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
APEX CLASS:
public with sharing class StoreFrontController_AC {
list<DisplayMerchandise> products;
public list<DisplayMerchandise> getProducts(){
if(products == Null){
products = new List<DisplayMerchandise>();
for(Merchandise__c item : [
SELECT Id,Name,Description__c,Price__c FROM Merchandise__c]){
products.add(new DisplayMerchandise(item));
}
}
return products;
}
// Inner class to hold online store details for item
public class DisplayMerchandise {
private Merchandise__c merchandise;
public DisplayMerchandise(Merchandise__c item) {
this.merchandise = item;
}
public String name {
get { return merchandise.Name; }
}
public String description {
get { return merchandise.Description__c; }
}
public Decimal price {
get { return merchandise.Price__c; }
}
public Boolean inStock {
get { return (0 < merchandise.Total_Inventory__c); }
}
public Integer qtyToBuy { get; set; }
}
}
for viewing the result,https://c.na31.visual.force.com/apex/Catalog_VF
Please help
<apex:pageBlock title="our products">
<apex:pageBlockSection columns="1">
<apex:pageBlockTable value="{!products}" var="pitem">
<apex:column headerValue="Product">
<apex:outputText value="{!pitem.Name}"/>
</apex:column>
<apex:column headerValue="Description">
<apex:outputText value="{!Description__c}"/>
</apex:column>
<apex:column headerValue="Price" style="text-align: right;">
<apex:outputText value="{0,number,currency}">
<apex:param value="{!pitem.Price}"/>
</apex:outputText>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
APEX CLASS:
public with sharing class StoreFrontController_AC {
list<DisplayMerchandise> products;
public list<DisplayMerchandise> getProducts(){
if(products == Null){
products = new List<DisplayMerchandise>();
for(Merchandise__c item : [
SELECT Id,Name,Description__c,Price__c FROM Merchandise__c]){
products.add(new DisplayMerchandise(item));
}
}
return products;
}
// Inner class to hold online store details for item
public class DisplayMerchandise {
private Merchandise__c merchandise;
public DisplayMerchandise(Merchandise__c item) {
this.merchandise = item;
}
public String name {
get { return merchandise.Name; }
}
public String description {
get { return merchandise.Description__c; }
}
public Decimal price {
get { return merchandise.Price__c; }
}
public Boolean inStock {
get { return (0 < merchandise.Total_Inventory__c); }
}
public Integer qtyToBuy { get; set; }
}
}
for viewing the result,https://c.na31.visual.force.com/apex/Catalog_VF
Please help
There is a simple thing which you are missing here.
Please add public in front of products list.
Please change your 2nd line :
FROM : list<DisplayMerchandise> products;
TO: public list<DisplayMerchandise> products;
Let me know if you still have any issue
Thanks,
Abhishek
Please save it correctly and verify it by opening on Browser that it contains the same code that u have written on eclipse or not.
Please save ur VF page and class directlt on browser as there may be some problem in SYNC with Eclipse.
Thanks,
Abhishek
anyways Thank u