I try to pass a parameter from Visualforce to the controller via apex:param
and then upsert the object in the controller. However, the parameter I passed on, "Field__c
" did not get written to the database. Here is my code:
<apex:commandButton value="Save" action="{!Save}">
<apex:param value="Saved" AssignTo="{!item.Field__c }" name="Saved"/>
</apex:commandButton>
Controller:
public PageReference Save() {
try {
item.NumberContacts__c = itemOld.NoContacts__c;
update item;
}
catch(Exception e){
System.debug('Exception occurred '+String.valueOf(e));
ApexPages.addMessages(e);
return null;
}
return null;
}
After reloading, item.Field__c
should get displayed on an output field on the Visualforce page, but after hitting the command button, it still displays the old value, not the value "Saved".
What do I miss here?
item
has theField__c
in its definition inside the controller? in other words, where isField__c
in the controller?