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
Dhananjaya BulugahamulleDhananjaya Bulugahamulle 

Why my code does not save the page information?

I have custom page, and when i try to save it my page does not save any information. I used different type of codes for saving. Most of them does not work and some of them break my page. Is there anything wrong with my code that i could not find? ( My main problem is it should save information and return to the same page with values) Any idea? Thanks
 
public class test1 {

    public Product_Brief__c pb {get;set;}
    public User u {get;set;}

    private ApexPages.StandardController controller {get;set;}
    public boolean bUpdate {get;set;}
    public string loggedinUserId = UserInfo.getUserId();
    public User u2 = [Select ContactId From User where Id =: '005R0000001Y6h4'];

    public String ctId{
        get {
                ctId = u2.ContactId;
                return ctId;
            }
        set;
    }

    Contact ct = [SELECT AccountId FROM Contact WHERE id=:ctId];
    public string getacct(){
        Account acct = [SELECT Name FROM Account WHERE id=:ct.AccountId];  
        return acct.Name;
        return null;
        }

    Opportunity opp = [SELECT Id FROM Opportunity WHERE AccountId=:ct.AccountId LIMIT 1];

   /* public PageReference save() {
        controller.save();{
        pageReference pg = new pageReference('/apex/pitu3');
        pg.setRedirect(true);
        pg .getParameters().put('id',controller.getId());
        return pg;
        }
        return null;
    } */

    /* public PageReference save() {
       controller.save(); 
       return null;
    }  */


   /* public PageReference save() {
    if(controller.save() != null) { 
    PageReference ref = Page.sumpage3; 
    ref.setRedirect(true); 
    return ref; 
    }
     return null;
    } */


    public PageReference save() {
        if(controller.save() != null) {
        PageReference congratsPage = Page.pitu3;
        congratsPage.setRedirect(true);
        congratsPage.getParameters().put('id',controller.getId());
        return congratsPage;
        }return null;
    }

    public test1(ApexPages.StandardController controller) {
        this.controller = controller;
    }

    public PageReference page1(){
    return Page.pitu1;
    }

    public PageReference page2(){
    return Page.pitu2;
    }

    public PageReference page3(){
    return Page.pitu3;
    }

    public PageReference page4(){  
    return Page.pitu4;
    }

    public PageReference page5(){
    return Page.pitu5;
    }

}

 
Pramodh KumarPramodh Kumar
you are no where updating the record in the save method. 
Sachin Sharma 3886Sachin Sharma 3886
update or insert staatement is missing in the SAVE action method....
William TranWilliam Tran
Did you resolve this?  It looks like you are saving it using controller.save() but did you ever bind VF page with anything like ?id=23842384324

or something else. 

Post your VF page if you still have issue and want to resolve it.

thx.
Dhananjaya BulugahamulleDhananjaya Bulugahamulle
Thanks for the information. I figure it out by myself. There is a problem with one of my feild.