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
SFDC_BigDogSFDC_BigDog 

List items

Hello,
Below are my Visual force and controller code. I would like display Account name as read only field from the list of items. 
Unfortunately I am getting error as Error: Unknown property 'VisualforceArrayList.name'

visualforce page:

<apex:page controller="AccountInformation">
<apex:form>
<apex:sectionHeader title="ACCOUNT DETAILS"/>
<apex:pageBlock title="Detailed Information">
<apex:pageBlockButtons location="top">
<apex:commandButton value="Save"/>
<apex:commandButton value="Cancel"/>
</apex:pageBlockButtons>

<apex:pageBlockSection title="Account Information">
<apex:pageBlockSectionItem>
Account Name <apex:outputText value="{!accountlist.name}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>


<apex:pageBlockSection title="Billing Information">
<apex:pageBlockSectionItem>
Billing Street <apex:outputText />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
Billing City <apex:outputText />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
Billing State <apex:outputText />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
Billing Country <apex:outputText />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
Billing PostalCode <apex:outputText />
</apex:pageBlockSectionItem>

</apex:pageBlockSection>



<apex:pageBlockSection title="Shipping Information">
<apex:pageBlockSectionItem>
Shipping Street <apex:outputText />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
Shipping City <apex:outputText />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
Shipping State <apex:outputText />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
Shipping Country <apex:outputText />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
Shipping Zipcode <apex:outputText />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:selectList>
</apex:pageBlock>
</apex:form>
</apex:page>



controller code:

public class AccountInformation
{

    public PageReference edit() {
    
    string str = apexpages.currentpage().getparameters().get('Accountid');
    System.debug('str+-------'+str);
    pagereference pg = new pagereference('/'+str+'/e');
        return pg;
    }







public list<Account> accountlist{get;set;}
public AccountInformation()
{
accountlist = new list<Account>();
accountlist = [SELECT Name,BillingStreet,BillingCity,BillingCountry,BillingPostalCode,BillingState,ShippingStreet,ShippingCity,ShippingCountry,ShippingPostalCode,ShippingState FROM Account order by Name asc
];

}








}
PrakashbPrakashb
Hi Varun,

In your page you are displaying data for one account but your controller has list of accounts.

if you want to display multiple records use iterators such as datatable/pageblocktable/repeat to display all account information.

If you want to display only one account data you can even use the standard controller as Account and use the controller variable directly.

If you want to use a custom controller instead of list<Account> just collect your account variable using an account object instead of list.

Thanks
Prakash 
 
SFDC_BigDogSFDC_BigDog
Hi prakash,

thanks for the reply.

What exactly do you mean by "controller variable directly"?
MithunPMithunP
Hi Varun,

Try below code for displaying single record details.

VF Page
=======
<apex:page controller="AccountInformation">
<apex:form>
<apex:sectionHeader title="ACCOUNT DETAILS"/>
<apex:pageBlock title="Detailed Information">
<apex:pageBlockButtons location="top">
<apex:commandButton value="Save"/>
<apex:commandButton value="Cancel"/>
</apex:pageBlockButtons>

<apex:pageBlockSection title="Account Information">
<apex:pageBlockSectionItem>
Account Name <apex:outputText value="{!accountRec.name}"/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>


<apex:pageBlockSection title="Billing Information">
<apex:pageBlockSectionItem>
Billing Street <apex:outputText />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
Billing City <apex:outputText />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
Billing State <apex:outputText />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
Billing Country <apex:outputText />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
Billing PostalCode <apex:outputText />
</apex:pageBlockSectionItem>

</apex:pageBlockSection>


<apex:pageBlockSection title="Shipping Information">
<apex:pageBlockSectionItem>
     Shipping Street <apex:outputText />
     </apex:pageBlockSectionItem>
     <apex:pageBlockSectionItem>
     Shipping City <apex:outputText />
     </apex:pageBlockSectionItem>
      <apex:pageBlockSectionItem>
         Shipping State <apex:outputText />
      </apex:pageBlockSectionItem>
      <apex:pageBlockSectionItem>
         Shipping Country <apex:outputText />
       </apex:pageBlockSectionItem>
       <apex:pageBlockSectionItem>
         Shipping Zipcode <apex:outputText />
       </apex:pageBlockSectionItem>
</apex:pageBlockSection>

</apex:pageBlock>
</apex:form>
</apex:page>
Class
=====
public class AccountInformation
{

    public PageReference edit() {
    
    string str = apexpages.currentpage().getparameters().get('Accountid');
    System.debug('str+-------'+str);
    pagereference pg = new pagereference('/'+str+'/e');
        return pg;
    }

public Account accountRec{get;set;}
public AccountInformation()
{
accountRec = new Account();
accountRec = [SELECT Name,BillingStreet,BillingCity,BillingCountry,BillingPostalCode,BillingState,ShippingStreet,ShippingCity,ShippingCountry,ShippingPostalCode,ShippingState FROM Account limit 1];

}
}

Best Regards,
Mithun.