+ Start a Discussion
SoundarSoundar 

Pagereference by visualforce page without Call Controller

Hi friends,

Is it possible to refresh a page from visualforce page witout calling an Apex Class. 

1. I saved one record from visualforce page, Now Record's are saved successfully. 
2. And still data's are enabled in relevant fields after records are saved.
3. Right Now i am using finally, it's Working wonderfully.
finally {
attachment = New Attachment();
}
4. And Now I want to refresh a page from visualforce Page itself without calling an apex Class / Controller.


********Sample Apex********
public with sharing class AttachmentUploadController {

    public AttachmentUploadController(){
      
    }
    
    Public Attachment attachment{
        
        get{
            if(attachment == Null){
                attachment = New Attachment();
            }
            return attachment;
        }
        set;
    } 
    
    Public Pagereference upload(){
        
        attachment.OwnerId = userInfo.getUserId();
        attachment.ParentId = ApexPages.currentPage().getParameters().get('Id');
        attachment.IsPrivate = False;
        try{
        Insert attachment;
            
        }Catch(DMLException e){
            ApexPages.addMessage(New ApexPages.message(ApexPages.Severity.ERROR,'Error uploading attachment'));
            return Null;   
            
        }
       finally{
            
            attachment = New Attachment();   // Solved By Using Finally ....
        }
        ApexPages.addMessage(New ApexPages.message(ApexPages.Severity.CONFIRM, 'Attachment uploaded successfully'));    
        //attachment = New Attachment();
        return Null;
        
    }
   

}

*********** Sample VF Page  *************

Thanks In Advance.


Regards,

Soundar