I have a VF page in which I am saving and adding the values through two buttons. Buttons are working fine. when i click the add button, a new row is added and when i click on save button,data is saved in Read only mode. But when i refresh the page , the values are saved in edit mode and not in read only mode. So, my questions is how to Save the Data in Read only mode on Page refresh.

  • DO you want Page to be readonly and editable based on specific conditions? May 25, 2016 at 10:54
  • yes. I have two buttons Add Row and Save Row and the page is placed on the detail page of a custom object. Before u Save the Row , all input fields are visible and when you click on Add row , one more editable row is added and when you Save the Row , the data is saved there itself in Read only mode. But when i refresh the page the data is stored in editable mode but I want i to store in Read only mode only and then when i click on Add button again the fields become editable. Please let me know if you are not able to understand.
    – user8305
    May 26, 2016 at 7:44

1 Answer 1


I faced a similar issue that you have faced. I used OutputField and inputfield both in order to make it available for readonly as well as edit mode.

<apex:inputField value="{!account.type}" rendered="{!ISNULL(account.id))}"/>
<apex:outputField value="{!account.type}" rendered="{!NOT(ISNULL(account.id)))}"/>

We have rendered tag in VF which allows us to conditionally decide when to decide a particular component. You can bring it into use. Here i have used id for this. if id is absent,ie record is not present so i will show the inputfield, if id is present so means we just wanna view it, and i will use outputfeild.

Notice the condition, u can club multiple conditions to allow/disallow edit of record on their particular stage


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .