4

i want a vf page that will render all the records through controller and the results will be render as html how please help me with some code and example for custom object.

Class:

public with sharing class Active {

    public Active(ApexPages.StandardController controller) {
    }

    public List<Property__c> po { get; set; }

    public Active(){
        po = [SELECT Acceptance_Date__c, Payment_Type__c, Date_Sold__c, Deposit_Manager_Approved__c, 
                     HardMoneyLoanMax__c, Buyer_Name_on_Contract__c ,Address__c, Property_Source__c,
                     Sales_Agent__c 
              FROM Property__c 
              WHERE Property__c.Property_Status__c = 'Active'];
    }
}

VF page:

<apex:page renderas="html" standardController="Property__c" 
           extensions="Active" showHeader="false" sidebar="false">

<apex:form >
    <apex:pageblock id="Property__c" title="PropertyDetails" >
        <apex:pageblockTable value="{!Property__c}" var="a">
            <apex:column value="{!a.County__c}"/>
            <apex:column value="{!a.Date_Sold__c}"/>
            <apex:column value="{!a.HardMoneyLoanMax__c}"/>
            <apex:column value="{!a.Notes__c}"/>
            <apex:column value="{!a.Property_Source__c}"/>
            <apex:column value="{!a.Sales_Agent__c}"/>
            <apex:column value="{!a.Date_Sold__c}"/>
            <apex:column value="{!a.Full_Bonus__c}"/>
            <apex:column value="{!a.Acceptance_Date__c}"/>
            <apex:column value="{!a.Deposit_Manager_Approved__c}"/>
            <apex:column value="{!a.Address__c}"/>  
        </apex:pageblockTable>
    </apex:pageblock>
</apex:form>

</apex:page>
4
  • 2
    Welcome to salesforce.stackexchange! That is a very broad and non specific question (or combination of questions) which is very hard to answer. Could you be more specific as to which part of this is a challenge to you, and what you've already done or understood yourself so far ? Commented Dec 24, 2013 at 9:16
  • my requirement is to display all the records in a single page so i have written vf page and controller for that need some more code
    – user4955
    Commented Dec 24, 2013 at 9:19
  • Can you update your question with the code you have ? And .. I would recommend you strongly think about showing ALL records. In due time those could be huge amounts, which will create strong challenges in terms of technical achievability and usability Commented Dec 24, 2013 at 9:27
  • added code above
    – user4955
    Commented Dec 24, 2013 at 9:36

3 Answers 3

2

While reading data from the Property__c object you don't need to reference this objects name if the WHERE clause:

po = [ SELECT  Acceptance_Date__c, ... 
       FROM Property__c 
       WHERE Property_Status__c = 'Active' ];

Then at the visualforce page you want to show all records from the po list? You need to use value="{!po}" in the pageBlockTable then:

<apex:pageblockTable value="{!po}" var="p">
        <apex:column value="{!p.County__c}"/>
        <apex:column value="{!p.Date_Sold__c}"/>
        <apex:column value="{!p.HardMoneyLoanMax__c}"/>
        ...
1
  • if i will use po in place of property it is now retrieving the values
    – user4955
    Commented Dec 24, 2013 at 11:33
1

Replace the below line this

<apex:pageblockTable value="{!Property__c}" var="a">

with this line

<apex:pageblockTable value="{!po}" var="a">

remove this construtor from class

public Active(ApexPages.StandardController controller) {
}

and standard controller attribute from visual force page and as below:

controller="Active" showHeader="false" sidebar="false">

Now you can get the records

3
  • it is not retrieving the value i should use output field also or no need
    – user4955
    Commented Dec 24, 2013 at 11:33
  • i edited the answer try out & let me know..
    – user4971
    Commented Dec 24, 2013 at 12:02
  • Thanks sravan now i got but i am not changed anything in controller only vf page changed
    – user4955
    Commented Dec 24, 2013 at 12:26
-3

My VF Page:

<apex:page standardController="Order__c" recordSetVar="display" cache="false" extensions="AllOrders" >
    <apex:form >
    <apex:pageBlock title="All Orders in Application">
        <apex:outputPanel id="mypanel">
            <apex:pageBlockTable value="{!display}" var="r">
                <apex:column headerValue="Name">
                    <apex:outputLink value="/{!r.Id}">{!r.Name}</apex:outputLink>
                </apex:column>


                <apex:column headerValue="Vendor" styleClass="ratingClass">
                <apex:outputText value="{!r.VendorDetail__c}" escape="false" />
                 </apex:column>



                <apex:column headerValue="Location">
                 <apex:outputText value="{!r.Location__c}" escape="false" />  </apex:column>

                <apex:column headerValue="Area">
                 <apex:outputText value="{!r.Area__c}" escape="false" />  </apex:column>

                <apex:column headerValue="Photoprint">
                   <apex:outputText value="{!r.Photoprint__c}" escape="false" />  </apex:column>

                <apex:column headerValue="Quantity">
                   <apex:outputText value="{!r.Quantity__c}" escape="false" />    </apex:column>

                <apex:column headervalue="Document print">
                   <apex:outputText value="{!r.Docprint__c}" escape="false" />    </apex:column>

                <apex:column headerValue="Quantity">
                  <apex:outputText value="{!r.DocQuantity__c}" escape="false" />    </apex:column>

            </apex:pageBlockTable>
        </apex:outputPanel>
    </apex:pageBlock>
    </apex:form>
</apex:page>

My Apex Class:

public with sharing class AllOrders {

private ApexPages.StandardSetController controller;
    public AllOrders(ApexPages.StandardSetController controller) {
    this.controller=controller;
}

public List<Order__c> display()
{
List<Order__c> po=[select Name,VendorDetail__c,Location__c,Area__c,Photoprint__c,Quantity__c,Docprint__c,DocQuantity__c from Order__c where Location__c = 'Hyderabad' ];

return po;
}
}

I can't get the records the way i am expecting, they are not filtered. The page is displaying all the rows. I dodnt understand where i made a mistake...please help me..in this.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .