You need to sign in to do that
Don't have an account?

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:
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:
All Answers
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>