You need to sign in to do that
Don't have an account?
![David VP David VP](https://dfc-org-production.my.site.com/img/userprofile/default_profile_45_v2.png)
Set or update standard object fields from controller extension ... why doesn't it work ?
A simple example based on what's in the VF docs :
<apex:page standardController="Account" extensions="myControllerExtension">
<apex:form >
<apex:PageBlock >
<apex:pageblockSection >
<apex:inputField value="{!account.name}"/>
<apex:inputfield value="{!account.website}"/>
</apex:pageblockSection>
<apex:commandButton value="Custom Action" action="{!customsave}"></apex:commandButton>
</apex:PageBlock>
</apex:form>
</apex:page>
... and the controller extensions :
public class myControllerExtension {
private final Account acct;
// The extension constructor initializes the private member
// variable acct by using the getRecord method from the standard
// controller.
public myControllerExtension(ApexPages.StandardController stdController) {
this.acct = (Account)stdController.getRecord();
}
public PageReference customsave() {
acct.website = 'somenewvalue';
return null;
}
}
I would image that the account object that's being held in the viewstate would get updated and that after the page refresh it would simply display the new in-memory value ... but it doesn't. In fact this code does nothing at all.
Am I thinking too much in 'managed beans' terms here ? What am I missing ?
Thanks,
David
<apex:page standardController="Account" extensions="myControllerExtension">
<apex:form >
<apex:PageBlock >
<apex:pageblockSection >
<apex:inputField value="{!account.name}"/>
<apex:inputfield value="{!account.website}"/>
</apex:pageblockSection>
<apex:commandButton value="Custom Action" action="{!customsave}"></apex:commandButton>
</apex:PageBlock>
</apex:form>
</apex:page>
... and the controller extensions :
public class myControllerExtension {
private final Account acct;
// The extension constructor initializes the private member
// variable acct by using the getRecord method from the standard
// controller.
public myControllerExtension(ApexPages.StandardController stdController) {
this.acct = (Account)stdController.getRecord();
}
public PageReference customsave() {
acct.website = 'somenewvalue';
return null;
}
}
I would image that the account object that's being held in the viewstate would get updated and that after the page refresh it would simply display the new in-memory value ... but it doesn't. In fact this code does nothing at all.
Am I thinking too much in 'managed beans' terms here ? What am I missing ?
Thanks,
David
Although like Ron suggested, you are always welcome to use rerender attribute to back you UI look ajaxy.
wrapping the apex:inputField into a apex:pageBlockSectionItem seems to correct the update issue. We're looking into getting this fixed.
Message Edited by dchasman on 06-25-2008 06:44 PM
thanks for the replies and confirming the issue (now I can sleep again :p ).
The workaround will do for now.
keep up the good work !!