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
Ranadheer chRanadheer ch 

i created example vf page but <apex:pagemassages is not working in that>

i created example vf page but <apex:pagemassages is not working in that> 

MY VF PAge: 

<apex:page controller="Mysecond" sidebar="false" >

<apex:form >
<apex:pageMessages ></apex:pageMessages>

<apex:pageBlock title="Create New Account">
<apex:pageblockButtons >
   <apex:commandButton action="{!resave}" value="Save" reRender="THe"/>
</apex:pageblockButtons>
  <apex:pageBlockSection Title="Account Information">
  <apex:inputField id="THE" value="{!Account.Name}"/>
  <apex:inputField id="IDS" value="{!Account.Phone}"/>
  </apex:pageBlockSection>
  <apex:pageblockTable value="{!tabledispaly}" var="t" id="THe">
  <!--<apex:column>
  <apex:inputCheckbox value="{!t.selected}"/>
  </apex:column>-->
  <apex:column value="{!t.Name}"/>
  <apex:column value="{!t.Phone}"/>
  </apex:pageblockTable>
  
</apex:pageBlock>
</apex:form>

</apex:page>


Controller:

public with sharing class Mysecond {

LIst<Account>tabledispaly= New LIst<Account>();
 Account account;
 
 
      public List<Account>gettabledispaly(){
      tabledispaly=[select id,name,phone from account];
      return tabledispaly;
      }
 
 public Account getAccount(){
 if(Account==null)
 account=New account();
 return account;
 }
 
 public void resave(){
 insert account;
   ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Saved Successfully'));
 
 //THis to send the user to detail page for new account
   // PageReference acctPage = new ApexPages.StandardController(account).view();
    //acctPage.setRedirect(False);
     // return acctPage;
 }
 
 
}


What can be the problem...THanks in advance:




 
Best Answer chosen by Ranadheer ch
sharathchandra thukkanisharathchandra thukkani
reRender the form (<apex:form id="fid">) instead of  <apex:pageblockTable id="THe">

All Answers

sharathchandra thukkanisharathchandra thukkani
reRender the form (<apex:form id="fid">) instead of  <apex:pageblockTable id="THe">
This was selected as the best answer
Swamy P R NSwamy P R N
HI Ranadheer,

By clicking command button you are callin one action method by the same time you are refreshing only pageblock table. You need to refresh form. So add  below code.
<apex:form id="fm">
 your code and
custom button change to   <apex:commandButton action="{!resave}" value="Save" reRender="fm"/>
</apex:form>
 
Ranadheer chRanadheer ch
Thanks swamy i changed it now it is working fine ...anyway thank u somuch for