You need to sign in to do that
Don't have an account?
hunkhere
How do I make VF Page as read-only after clickin of Submit/save button
Hello Everyone,
I have a requirement, when users fills the data in the VF Page and clicks save/submit button, after clciking the VF Page should be Read-only and should not be editable.
Please help me out
Thanks
You'll need to flip all of your input fields to output fields. You can do this by setting a 'readonly' boolean or similar in your controller, and then having page markup like the following:
when I save the record it shows read-only, but when I refresh the same record on VF page by pressing F5 record still the fields are editable .
I am setting up a getter setter varibale for a boolean like
public boolean Filed_Name{get;set;}
and in save method I am flipping the boolean variable to True.
By hitting F-5 you have refreshed the page and I'd expect this to create a new instance of the controller, which would mean the booleans default back to false. Does this page allow creation of records or editing of existing records? If the latter, you'll need to mark the record as no longer allowed to be edited.
Yes this page is used to create the records, once click on save button the entire page should get read-only, should not be editable after save even if you press F-5
When you press F-5, do the values remain in the fields and become editable or are they blanked out?
after saving if I pressed F-5 the fileds should go read-only should not be editable again.
I got that - I'm asking what is actually happening.
Currently after pressing F-5 Records are still editable
if I save recod fields are getting read-only
and if I press F-5 again page is editable...actually it should show read only
When you press F-5, do the values remain in the fields and become editable or are they blanked out?
when I press F-5 the values are getting displaying and editable, actullay it should not be editable. The field values should remain as read-only after I press F-5
Do you flip the booleans to display each time the form is submitted - i.e. you reverse the existing value?
HI,
here is my code follows
Controller:
public class myClass {
public boolean readonlyflag {get;set;}
public myClass(ApexPages.StandardSetController stdController) {
readonlyflag = flase;
}
public PageReference saveInfo() {
System.debug('saving Record');
try {
upsert(record);
readonlyflag = true;
}
catch(System.DMLException e) {
ApexPages.addMessages(e);
for (Integer i = 0; i < e.getNumDml(); i++) {
System.debug(e.getDmlMessage(i));
}
return null;
}
}
VF PAge:
<apex:page controller="mycontroller" showHeader="false" sidebar="false" >
<apex:pageBlockSectionItem >
<apex:outputLabel value="Date of Birth" for="FIELD" title="{!$ObjectType.OBJ__c.Fields.DOB__c.inlineHelpText}" rendered="{!NOT(readonlyflag)}"/>
<apex:InputField id="FIELD" required="false" value="{!OBJ.DOB__C}" rendered="{!NOT(readonlyflag)}"/>
</apex:pageBlockSectionItem>
<!-- Read-Only -->
<apex:pageBlockSectionItem >
<apex:outputLabel value="Date of Birth" for="FIELDRO" title="{!$ObjectType.OBJ__c.Fields.DOB__C.inlineHelpText}" rendered="{!readonlyflag}"/>
<apex:OutputField id="FIELDRO" value="{!OBJ.DOB__C}" rendered="{!readonlyflag}"/>
</apex:pageBlockSectionItem>
BUTTONS:
<apex:pageBlockButtons >
<apex:commandButton action="{!saveInfo}" value="Save"/>
</apex:pageBlockButtons>
</apex:page>
This implies that there is a new instance of the controller being created - the readonly flag is only set to false in the constructor. I suspect the browser is being helpful by retaining the previously entered value. The only way I can think of to handle this is to redirect the user to the readonly page. That way if they refresh it will just hit the readonly page again.
I have similar request , could you please help. :(
Regards,
Shobhit
How to make visualforce page read only and need to get the count entered by each user on that particulat vf page.
Thanks,
Vineela.