my problem is ...after saving,the record is not getting in Pageblock 2.how to get the record automatically after save the record
<apex:page Controller="siteportal" showHeader="false" id="pageId">
<apex:form id="formid">
<apex:pageBlock id="pb1" >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!Save}" />
</apex:pageBlockButtons>
<apex:pageMessages ></apex:pageMessages>
<apex:pageBlockSection >
<apex:inputField value="{!emp1.Name}" required="false"/>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock id="abc">
<apex:pageBlockTable value="{!emp}" var="acc" >
<apex:column headerValue="Action" >
<apex:outputLink value="/apex/siteportalvf?id={!acc.id}" >Edit</apex:outputLink>
<apex:param name="param" assignTo="{!acc.id}" value="param"/>
|
<a href="javascript:if (window.confirm('Are you sure?')) DeleteAccount('{!acc.Id}');" style="font-weight:bold" >Del</a> |
<apex:commandLink action="{!saveEdit}">Save </apex:commandLink>
</apex:column>
<apex:column headerValue="account name">
<apex:outputfield value="{!acc.name}" >
<apex:inlineEditSupport event="onclick" />
</apex:outputfield>
</apex:column>
<apex:column headerValue="phone">
<apex:outputfield value="{!acc.phone}" >
<apex:inlineEditSupport event="onclick" />
</apex:outputfield>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:actionFunction action="{!DeleteAccount}" name="DeleteAccount" reRender="form" >
<apex:param name="accountid" value="" assignTo="{!SelectedAccountId}"/>
</apex:actionFunction>
<apex:pageblock id="block3">
<apex:pageblockTable value="{!acclist1}" var="acc">
<apex:column headerValue="Account Name">
<apex:inputText value="{!acc.Name}"></apex:inputText>
</apex:column>
<apex:column headerValue="Account Phone">
<apex:inputText value="{!acc.Phone}"></apex:inputText>
</apex:column>
<apex:column >
<apex:commandButton value="Update" action="{!UpdateAcc}" reRender="pageId,abc,pb1"/>
</apex:column>
<apex:pageMessages ></apex:pageMessages>
</apex:pageblockTable>
</apex:pageblock>
</apex:form>
</apex:page>
controller
public class siteportal {
public boolean DisplayContacts{get;set;}
public string Employeename {set;get;}
public string SelectedAccountId {get; set;}
public string save {set;get;}
public List<Account> emp {get;set;}
public Account emp2 {get;set;}
public Account emp1 {get;set;}
public boolean showemp{get;set;}
public List<Account> accList {get;set;}
public List<Account> accList1 {get;set;}
public Account editContact { get; set; }
public Boolean rendered{set;get;}
public string accID{get;set;}
public siteportal() {
setupAccount();
emp1=new Account();
emp = [Select id,name,phone from Account where createddate=today];
showemp=true;
accID=apexpages.currentpage().getparameters().get('accID');
accList1 = [Select id,Name,Phone from Account where ID =: ApexPages.currentPage().getParameters().get('id') ];
}
public void setupAccount(){
accList = [Select name, id from Account ];
}
public void save(){
upsert emp1;
ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,'Record Created Successfully.Thank you!'));
}
public void UpdateAcc(){
update accList1;
ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM,'Record Updated Successfully.Thank you!'));
}
public void DeleteAccount(){
Account del = new Account(ID=SelectedAccountId);
delete del;
setupAccount();
}
public String getParam(String name) {
return ApexPages.currentPage().getParameters().get(name);
}
public PageReference add() {
DisplayContacts=true;
return null;
}
public PageReference saveEdit() {
UPDATE Emp;
return null;
}
}