You need to sign in to do that
Don't have an account?
srilatha
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
That smacks that the account property in your controller is a string rather than an sobject instance.
All Answers
That smacks that the account property in your controller is a string rather than an sobject instance.
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.
Of course you can - you just have to have a public property in the controller named 'Account' that has a public getter.
another question
after i saved the input field that input field box must be cleared
how can we acehive this
What do you mean by after you've saved the input field? Do you mean after you've saved the record?
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
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:
then when the page is refreshed, any inputs backed by the account object will be empty.
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'
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.