You need to sign in to do that
Don't have an account?
Partner Portal display pulling data from custom object
I am trying to pull data from four custom fields on my custom object to display them in my visual force page. I have only been using salesforce for a few days, and I am completely stuck.
I have custom object: Book
with custom fields: Book Title, Author Name, Book Cost, Book Genre
I want to loop through each record on my custom object and display them on my visual force page in my partner portal. I have an Apex class:
public class getAllBooks {
public getAllBooks(ApexPages.StandardController Controller) {
}
public Books__c[]getBookDetail(){
Book__c[]bookList;
bookList = [SELECT Books__c.Book_Title__c,
Book__c.Author_Name__c,
Book__c.Book_Cost__c,
Book__c.Book_Genre__c
FROM Book__c];
return bookList;
}
}
and my VF page:
<apex:page standardController="Books__c" extensions="getAllBooks"
<apex:form>
<apex:pageBlock>
<apex:PageBlockTable value="{!getAllBooks}" var="book">
<apex:column value="{!book.Book_Title__c}" headerValue="Book Title" />
<apex:column value="{!book.Author_Name__c}" headerValue="Author Name" />
<apex:column value="{!book.Book_Cost__c}" headerValue="Book Cost" />
<apex:column value="{!book.Book_Genre__c}" headerValue="Book Genre" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Error: Unknown property 'Book_cStandardController.getAllBooks'
I have no idea what to try next.
Any suggestions would be helpful. Laymens terms are also helpful, as I am not the sharpest Apex/Visualforce programmer around!
Thanks in advance.
Hi,
Try the below code snippet as reference:
---------- apex class-----------
public class getAllBooks {
public Books__c bookList{get;set;}
public getAllBooks(ApexPages.StandardController Controller) {
}
public Books__c[] getBookDetail(){
{
bookList=new Books__c();
bookList = [SELECT id,Book_Title__c,Author_Name__c,Book_Cost__c,Book_Genre__c FROM Book__c];
return bookList;
}
}
----------------- vf page-------------
<apex:page standardController="Books__c" extensions="getAllBooks">
<apex:form>
<apex:pageBlock>
<apex:PageBlockTable value="{!BookDetail}" var="book"> <!-- change getAllBooks with BookDetail -->
<apex:column value="{!book.Book_Title__c}" headerValue="Book Title" />
<apex:column value="{!book.Author_Name__c}" headerValue="Author Name" />
<apex:column value="{!book.Book_Cost__c}" headerValue="Book Cost" />
<apex:column value="{!book.Book_Genre__c}" headerValue="Book Genre" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
All Answers
Hi,
Try the below code snippet as reference:
---------- apex class-----------
public class getAllBooks {
public Books__c bookList{get;set;}
public getAllBooks(ApexPages.StandardController Controller) {
}
public Books__c[] getBookDetail(){
{
bookList=new Books__c();
bookList = [SELECT id,Book_Title__c,Author_Name__c,Book_Cost__c,Book_Genre__c FROM Book__c];
return bookList;
}
}
----------------- vf page-------------
<apex:page standardController="Books__c" extensions="getAllBooks">
<apex:form>
<apex:pageBlock>
<apex:PageBlockTable value="{!BookDetail}" var="book"> <!-- change getAllBooks with BookDetail -->
<apex:column value="{!book.Book_Title__c}" headerValue="Book Title" />
<apex:column value="{!book.Author_Name__c}" headerValue="Author Name" />
<apex:column value="{!book.Book_Cost__c}" headerValue="Book Cost" />
<apex:column value="{!book.Book_Genre__c}" headerValue="Book Genre" />
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.