Skip to main content
2 of 2
Code formatted
Sergej Utko
  • 22.1k
  • 11
  • 60
  • 88

Modify visualforce input before saving and before reaccessing

Here's the scenario.

(a) In standard controller extension for Custom_Object__c, we define custObj as

public Custom_Object__c custObj{get;set;}

(b) In visualforce we have an input field

<apex:inputField id="commentfield" value="{!custObj.Comments__c}"/>

Now here's the scenario i was wondering if could be implemented or not,

  1. User enters his comment in commentfield.
  2. A method in controller extension modifies the input here before saving. (For eg. add system.now() timestamp after the comment) [[How will this method access the entered value to modify it and save it back to the record??]]
  3. Custom Object's record is saved with the modified input via standard {!Save} method in visualforce.
  4. When user access the same record this field needs to appear blank(How to make it appear blank in VF page or should I clear the field value right after saving?) and when the user enters new comment, that comment should have it's own timestamp and be concatenated with comment in step 1-3.

Thanks for the insights!!

Raish
  • 707
  • 11
  • 28