+ Start a Discussion
Simha YadavSimha Yadav 

i want to make field values dissaper after clicking on save button in custom visual force page,please Help anybody below is Pic and my code

please look at this pic
<apex:page controller="Pagination_min"  showHeader="false" sidebar="false"  extensions="AccountController">
  <apex:form >
    <apex:pageBlock >
        <apex:pageBlockSection columns="1"  title="Accounts"> 
            <apex:pageBlockTable value="{!accounts}" var="a">
                <apex:column >
                   <apex:outputLink title="" value="/{!a.id}/e?retURL=/apex/{!$CurrentPage.Name}" style="font-weight:bold">Edit</apex:outputLink>&nbsp;|&nbsp;

                </apex:column>
                <apex:column value="{!a.Name}"/>
                <apex:column value="{!a.Type}"/>
                <apex:column value="{!a.BillingCity}"/>
                <apex:column value="{!a.BillingState}"/>
                <apex:column value="{!a.BillingCountry}"/>
            </apex:pageBlockTable>
            <apex:panelGrid columns="7">
            <apex:commandButton value="|<" action="{!setcon.first}" disabled="{!!setcon.hasPrevious}" title="First page"/>
            <apex:commandButton value="<" action="{!setcon.previous}" disabled="{!!setcon.hasPrevious}" title="Previous page"/>
            <apex:commandButton value=">" action="{!setcon.next}" disabled="{!!setcon.hasNext}" title="Next page"/>
            <apex:commandButton value=">|" action="{!setcon.last}" disabled="{!!setcon.hasNext}" title="Last page"/>
           
             <apex:outputText >{!(setCon.pageNumber * size)+1-size}   -    {!IF((setCon.pageNumber * size)>noOfRecords, noOfRecords,(setCon.pageNumber * size))} of {!noOfRecords}</apex:outputText>
                <apex:commandButton value="Refresh" action="{!refresh}" title="Refresh Page"/>
            </apex:panelGrid>
        </apex:pageBlockSection>
     </apex:pageBlock>
                      <apex:pageBlock title="My Content" mode="edit">
                          <apex:pageBlockButtons >
                               <apex:commandButton action="{!save}" value="Save" reRender="pb"/>
                          </apex:pageBlockButtons>
                               <apex:pageBlockSection title="My Content Section" columns="2">
                                    <apex:inputField value="{!account.name}" required="false"/>
                                    <apex:inputField value="{!account.type}"/>
                                    <apex:inputField value="{!account.Billingcity}"/>
                                    <apex:inputField value="{!account.billingstate}"/>
                                    <apex:inputField value="{!account.billingcountry}"/>
                               </apex:pageBlockSection>
                      </apex:pageBlock>
  </apex:form>               
</apex:page>
**************************************************************************************
public class Pagination_min {

    Public Integer noofRecords {get; set;}
    public integer size {get; set;}
   
    public Apexpages.standardsetController setcon{
        get{
            if(setCon == null){
                size = 10;
                String queryString = 'Select Name, Type, BillingCity, BillingState, BillingCountry from Account order by Name';
                setcon = new apexpages.standardsetController(Database.getquerylocator(queryString));
                setcon.setpagesize(size);
                noofRecords = setcon.getResultsize();
            }
            return setcon;
        }
         set;
    }
    Public list<Account> getAccounts(){
        list<Account> acclist = new list<Account>();
         for(Account ac : (list<Account>)setcon.getrecords()){
             acclist.add(ac);
         }
        return accList;
       
      
    }
   Public PageReference Refresh(){
       
        setcon=null;
        getAccounts();
        setcon.setpageNumber(1);
       
        return null;
    }
}
**********************************************************************
public with sharing class AccountController {
   
    public Account account{get; set;}
    public AccountController(Pagination_min controller) {
      account = new Account();
    }
    
    public void save(){
        upsert account;
    }
}
alsinan nazimalsinan nazim
Hi Simha Murthy,

This is becouse after the save action, the value is still available in the view state. So the same is showing in the fields after the action is executed too. So try nullify the same after the insert.
Like after your upsert try,
account=null;
return null;

Please check the following link too.
http://stackoverflow.com/questions/17465677/unable-to-clear-the-fileds-after-saving-the-data-using-apex-code
Regards
Alsinan
 
Simha YadavSimha Yadav
@alsinan,it is not working bro

Getting below error,

Attempted to upsert a null list Error is in expression '{!save}' in component <apex:commandButton> in page task1: Class.AccountController.save: line 9, column 1 Class.AccountController.save: line 9, column 1