You need to sign in to do that
Don't have an account?

A visualforce page that allows to create a new account and display all accounts in a table
Hi I am a newbie to visualforce. I am trying to create a visualforce page that displays all the accounts in a table and a form that allows to save accounts. I have written coding but facing issues.
Following is my visualpage sourcecodes.
Following is my visualpage sourcecodes.
<apex:page controller="AddAccountController" tabStyle="Account" showHeader="false" sidebar="false"> <apex:form > <apex:pageBlock title="Add Account"> <apex:pageBlockSection title="Account Details" columns="1"> <apex:inputField value="{!Account.name}" /> <apex:inputField value="{!Account.site}"/> <apex:inputField value="{!Account.type}"/> <apex:inputField value="{!Account.accountNumber}"/> <apex:commandButton value="Save" action="{!save}"> <apex:commandButton value="Cancel" action="#"> </apex:commandButton> </apex:commandButton> </apex:pageBlockSection> <apex:pageBlockTable value="{!Account}" var="account"> <apex:column value="{!account.Name}"/> <apex:column value="{!account.Site}"/> <apex:column value="{!account.type}"/> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>Here on its my AddAccountController class
public class AddAccountController { public List <Account> account=new List <Account>(); public Account act{get;set;} public AddAccountController() { account = [SELECT Id, Name, Site FROM Account]; } public List <Account> getAccount() { return account; } public PageReference save() { upsert (account); return null; } }
Could not resolve the entity from <apex:inputField> value binding '{!account.name}'. <apex:inputField> can only be used with SObjects, or objects that are Visualforce field component resolvable.This is the error that i get. Please experts help a newbie :).
{!account.name} is resolved is there is a standard controller, a getter account returning a single account or a property named account.
Here, there are a list for the getter and the name is act for the property
<apex:inputField value="{!act.name}" />
The following code is what you are trying to do
Use also: <apex:pageBlockButtons> for the block of buttons.
Best regards
Alain