You need to sign in to do that
Don't have an account?
SFDC_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
];
}
}
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
];
}
}
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
thanks for the reply.
What exactly do you mean by "controller variable directly"?
Try below code for displaying single record details.
VF Page
======= Class
=====
Best Regards,
Mithun.