function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nagarjuna Reddy NandireddyNagarjuna Reddy Nandireddy 

HOW TO WRITE A VF PAGE TO READ ONLY FIELDS

Hi,
i need help from tou 
How to write a code to given scenario
User-added image
this is my vf page in this vf page insert values and click on save button.
After click of save button record will save and it will redirecting to object.
here i dont want to go object record page. after click of save button record save and page will redirect same vf page like below
User-added image
sridhar v 7sridhar v 7
Hi,

Try below, i believe this should work for you.

public pagereference save(){
// logic for save below
.......
.......
......
// DML save
pagereference pg = new pagereference('/apex/yourvfpageName');
pg.setredirect(true);
return pg;   
}

Thanks,
Harish RamachandruniHarish Ramachandruni
hi,

Use insted of inputfield outputfirld .

 
<apex:outputField value="{!opportunity.name}"/>
<apex:outputField value="{!opportunity.amount}"/>




regards,
Harish.R.
Prashant Pandey07Prashant Pandey07
Public with sharing yourClassName{

Opportunity opp;
//Class body

Public Pagereference save(){

pagereference pgref = new pagereference('/apex/VfPageName');
pg.setredirect(true);
return pgref;   
}

 
Nitesh K.Nitesh K.
Use this
<apex:Page StandardController="Opportunity" Extensions="oppExt">
<apex:inputfield value="{!opp.Name}" rendered="{!!oppFlag}"/>
<apex:inputfield value="{!opp.StageName}" rendered="{!!oppFlag}"/>
<apex:inputfield value="{!opp.Amount}" rendered="{!!oppFlag}"/>


<apex:outputfield value="{!opp.Name}" rendered="{!oppFlag}"/> 
<apex:outputfield value="{!opp.StageName}" rendered="{!oppFlag}"/> 
<apex:outputfield value="{!opp.Amount}" rendered="{!oppFlag}"/>

</apex:page>
 
public class oppExt{
public Boolean OppFlag{get;set;}
public Opportunity opp{get;set;}
public oppExt(ApexPages.StandardController std){
opp=new Opportunity();
OppFlag=false;

if(std.getId()!=null){
OppFlag=true;
opp=(Opportunity)std.getRecord();
}
}
//Redirect same vf
Public Pagereference save(){ 
if(oppFlag)
Insert opp;
pagereference pgref = new pagereference('/apex/VfPageNameid?='+opp.Id).setredirect(true); 
return pgref; 
}

}

Let me know if this helps.