+ Start a Discussion
Sascha DeinertSascha Deinert 

Save Button doesn't work

Hi, 

If I click the save button, the pageblock refreshed but the values still the same.
Could you help me with this error.

Thanks,
Sascha
 
public class VTP21_class {

Public String SelectedUserId {get; set;}
Public String SelectedOppId {get; set;}

Private Opportunity OppSave;

Public List <Opportunity> getOppDList2() {
    List <Opportunity> OppD = [SELECT Id, Name, Amount FROM Opportunity WHERE Id = :SelectedOppId];
        IF (SelectedOppId != NULL) {
            OppSave = [SELECT Id FROM Opportunity WHERE Id = :SelectedOppId];
        }
    RETURN OppD;
} 

Public pageReference getOppDList() {
    getOppDList2(); 
    RETURN NULL; 
}

Public PageReference SaveInlineChanges() {
    UPDATE OppSave;
    RETURN NULL;
}


Public PageReference CancelInlineChanges() {
    RETURN ApexPages.CurrentPage();
}

}
 
<apex:pageblock id="pbOppD" mode="inlineEdit">
    <apex:pageBlockButtons location="top">
        <apex:commandButton action="{!SaveInlineChanges}" value="Save" id="saveButton" rerender="pbOpp ,pbOppD"/> -->
        <apex:commandButton action="{!CancelInlineChanges}" value="Cancel" id="cancelButton"/>
    </apex:pageBlockButtons>
    <apex:pageBlockSection >
        <apex:pageblocktable value="{!OppDList2}" var="OppD">
            <apex:column headervalue="Name">
                <apex:outputfield value="{!OppD.Name}" />
            </apex:column>        
            <apex:column headervalue="Amount">
                <apex:outputfield value="{!OppD.Amount}" />
            </apex:column>
        </apex:pageblocktable>   
    </apex:pageBlockSection>
</apex:pageblock>

 
Best Answer chosen by Sascha Deinert
Nitin PaliwalNitin Paliwal
Hi,
The reference variable which you are saving is not binded to VF page , thats why it is not saving.

Try this code,

public class VTP21_class {

Public String SelectedUserId {get; set;}
Public String SelectedOppId {get; set;}
public VTP21_class(){
    getOppDList2();
}
Private Opportunity OppSave;
public List <Opportunity> OppD1{get;set;}
Public List <Opportunity> getOppDList2() {
    OppD1 = [SELECT Id, Name, Amount FROM Opportunity WHERE Id = '006i000000GkOMr'];
        IF (SelectedOppId != NULL) {
            OppSave = [SELECT Id FROM Opportunity WHERE Id = '006i000000GkOMr'];
        }
    RETURN OppD1;
}

Public pageReference getOppDList() {
    getOppDList2();
    RETURN NULL;
}

Public PageReference SaveInlineChanges() {
    UPDATE OppD1;
    RETURN NULL;
}


Public PageReference CancelInlineChanges() {
    RETURN ApexPages.CurrentPage();
}

}


Page---
<apex:pageblock id="pbOppD" mode="inlineEdit" >
    <apex:pageBlockButtons location="top">
        <apex:commandButton action="{!SaveInlineChanges}" value="Save" id="saveButton" rerender="pbOpp ,pbOppD"/> -->
        <apex:commandButton action="{!CancelInlineChanges}" value="Cancel" id="cancelButton"/>
    </apex:pageBlockButtons>
    <apex:pageBlockSection >
        <apex:pageblocktable value="{!OppD1}" var="OppD">
            <apex:column headervalue="Name">
                <apex:outputfield value="{!OppD.Name}" />
            </apex:column>       
            <apex:column headervalue="Amount">
                <apex:outputfield value="{!OppD.Amount}" />
            </apex:column>
        </apex:pageblocktable>  
    </apex:pageBlockSection>
</apex:pageblock>

Thanks
Nitin