[SalesForce] redirect to parent record visualforce page

I am using the below method in button tag in visualforce page. After insert i want to redirect to the parent record detail page. currently it is not happening. Please help.

public class BIAcontroller
{
    public BIAcontroller(ApexPages.StandardController controller)
    {
        account=new BIA__c();
        // other constructor operations
    }

    public BIA__c account{ get; set; }
    // other properties

    public PageReference processSelected() 
    {
        //do stuff
        insert account;

        PageReference nextPage = new PageReference('/' + account.id);
        // nextPage.setRedirect(true);
        return nextPage;
    }
}

Best Answer

Generally if I have an SObject and I want to redirect to it via PageReference, I will use the following:

SObject record; // can be of any type
PageReference view = new ApexPages.standardController(record).view();
Related Topic