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
nagalakshminagalakshmi 

How to display the total account object in visual force page with out using controller

Hi,

 

        I want to display the total account records and detail page of those records in visual force page. But i want to display the the records and detail page in visual force page only using visual force page code and  with out using the controller. Any one please help me how to reach the requirement.

 

Thanks,

Lakshmi.

Best Answer chosen by Admin (Salesforce Developers) 
mtbclimbermtbclimber

I think this is what you are after:

 

 

<apex:page standardController="account" recordSetVar="accounts" sidebar="false" showHeader="false">
    <apex:panelGrid columns="2">
        <apex:form >
            <apex:pageBlock>
                <apex:pageBlockTable value="{!accounts}" var="a">
                    <apex:column headerValue="Name" >
                        <apex:commandLink value="{!a.name}" reRender="out">
                            <apex:param name="id" value="{!a.id}"/>
                        </apex:commandLink>
                    </apex:column>
                </apex:pageBlockTable>
            </apex:pageBlock>
        </apex:form>
        <apex:outputPanel id="out">
            <apex:detail subject="{!$CurrentPage.parameters.id}" relatedList="false" title="false"/> 
        </apex:outputPanel>
    </apex:panelGrid>
</apex:page>

 

 

All Answers

Afzal MohammadAfzal Mohammad

You can use something like this. Its an extract from VF dev guide.

 

 

<!-- For this example to render properly, you must associate the Visualforce page
with a valid account record in the URL.
For example, if 001D000000IRt53 is the account ID, the resulting URL should be:
https://Salesforce_instance/apex/myPage?id=001D000000IRt53
See the Visualforce Developer's Guide Quick Start Tutorial for more information. -->
<apex:page standardController="Account">
<apex:detail subject="{!account.ownerId}" relatedList="false" title="false"/>
</apex:page>

 Hope that helps.

 

Afzal

 

nagalakshminagalakshmi

Hi afzal,

         Thank you for your reply. But my requirement is not like that. with out passing the id in url we want to reach the requirement.

 

 

Thanks,

Lakshmi.

Afzal MohammadAfzal Mohammad

Hmm, in that case you may try this. Below code will list accounts in a tabular format.

 

 

<apex:page>
<apex:enhancedList type="Account" height="300" rowsPerPage="10" id="AccountList" />
</apex:page>

 

 

Hope that helps.

 

Afzal

mtbclimbermtbclimber
You should be able to do this with the standardsetcontroller and the detail component by binding the link fir the given account name in the list to the Id for detail with a request param.

The issue with the enhancedList or listViews is that you can't control the link behavior.
nagalakshminagalakshmi

Hi,

 

Actually my code is

 

 

<apex:page standardController="account"
    recordSetVar="accounts"
    sidebar="false" showHeader="false">
    <apex:form >
  <apex:pageBlock >
    <apex:pageBlockTable value="{!accounts}"
      var="position">
    <apex:column headerValue="Name" >
  <!--<apex:commandLink value="{!position.name}">
   <apex:param name="oid" value="{!position.id}"/>-->
   <apex:detail subject="{!position.id}" relatedList="false" title="false"/> 
   <!--</apex:commandLink>-->
  </apex:column>
    <apex:column value="{!position.phone}"/>
     </apex:pageBlockTable>
  </apex:pageBlock>
  </apex:form>
</apex:page>

 

It displays the detail page continuously.But i want to display the names list in page block table and when i am click on that name it will display the detail page. how to solve these please any help me.

 

 

Thanks,

Lakshmi

mtbclimbermtbclimber

I think this is what you are after:

 

 

<apex:page standardController="account" recordSetVar="accounts" sidebar="false" showHeader="false">
    <apex:panelGrid columns="2">
        <apex:form >
            <apex:pageBlock>
                <apex:pageBlockTable value="{!accounts}" var="a">
                    <apex:column headerValue="Name" >
                        <apex:commandLink value="{!a.name}" reRender="out">
                            <apex:param name="id" value="{!a.id}"/>
                        </apex:commandLink>
                    </apex:column>
                </apex:pageBlockTable>
            </apex:pageBlock>
        </apex:form>
        <apex:outputPanel id="out">
            <apex:detail subject="{!$CurrentPage.parameters.id}" relatedList="false" title="false"/> 
        </apex:outputPanel>
    </apex:panelGrid>
</apex:page>

 

 

This was selected as the best answer
nagalakshminagalakshmi

Hi,

 

Thank you very so much. its working. But it displays only some records, not all records of account. How to display all records of account.

 

 

Thanks,

Lakshmi.

mtbclimbermtbclimber

StandardSetController provides pagination and is not intended to show "all" records for a given object. It is also controlled by the filter that was last chosen by the user on the respective standard list page. Check out the Visualforce doc for more info.

MeenakshmiMeenakshmi

Keep on adding following section in between <apex:pageBlockTable /> tag with variable api names of account fields in 'headerValue' and 'value' attribute. Columns will be increasing.

<apex:column headerValue="Name" >
                        <apex:commandLink value="{!a.name}" reRender="out">
                            <apex:param name="id" value="{!a.id}"/>
                        </apex:commandLink>
                    </apex:column>