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
srilathasrilatha 

unknown property string.name

while am trying to change this vf page to controller am getting this error

 

<apex:page controller="MyController" tabStyle="Account">
<apex:form>
<apex:pageBlock title="Hello {!$User.FirstName}!">
You are viewing the {!account.name} account. <p/>
Change Account Name: <p/>
<apex:inputField value="{!account.name}"/> <p/>
<apex:commandButton action="{!save}" value="Save New Account Name"/>
</apex:pageBlock>
</apex:form>
</apex:page>

 

please give me the solution

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

That smacks that the account property in your controller is a string rather than an sobject instance.

All Answers

bob_buzzardbob_buzzard

That smacks that the account property in your controller is a string rather than an sobject instance.

This was selected as the best answer
MagulanDuraipandianMagulanDuraipandian

standardController="account" extensions="MyController"

 

You cannot use {!account.name}, if you dont mention standardController="account".

 

Regards,

Magulan D

Salesforce.com certified Force.com Developer.

SFDC Blog

 

If this post is your solution, kindly mark this as the solution.

bob_buzzardbob_buzzard

Of course you can - you just have to have a public property in the controller named 'Account' that has a public getter.

srilathasrilatha

another question 

 

after  i saved the input field that input field box must be cleared

 

how can we acehive this

bob_buzzardbob_buzzard

What do you mean by after you've saved the input field?  Do you mean after you've saved the record?

srilathasrilatha

yeah, after saving the record.

 

 

yes, after saving the record also my input field contain the same value. 

   if i want to fill a new value am erasing the old value and filling the nw value

bob_buzzardbob_buzzard

When you save the record, if you are allowing the user to create a new account, you should instantiate a new account record.

 

Something like:

 

public PageReference save()
{
   insert account;
   account=new Account();

   return null;
}

 then when the page is refreshed, any inputs backed by the account object will be empty.

webnerswebners
can you provide solution for this
public class MyController{
Private final Contact contact;
public List<Contact> getcontactstatus()
{
return[SELECT Name FROM Contact WHERE status__c = 'static'];
}
}
throwing error

Error: Unknown property 'MyController.contact'
bob_buzzardbob_buzzard

Yes - for a controller property to be accessible to a Visualforce page it must be public with a public getter and setter.  Your contact in the controller is private.