View

Wednesday, May 1, 2013

Apex Coding on EDIT CONTROLLER / EDIT PAGE.....

---------------------------------------EDIT CONTROLLER-------------------------------------


public class talend1
{
public talend1(ApexPages.StandardController Controller)
{
String ParentId = System.currentPageReference().getParameters().get('idfield');
}

Talend__c talend;
public Talend__c gettalend()
{
if(talend == null)
{
   //talend = new Talend__c();
   String recordidvalue= System.currentPageReference().getParameters().get('idfield');
   talend = [Select t.Id,t.Name__c,t.Opportunity__c,t.Phone__c,t.Account__c,t.Company__c from Talend__c t where t.Id=:recordidvalue];
}
return talend;
}
public PageReference Save1()
{
Talend__c t = new Talend__c();
 String eventid= System.currentPageReference().getParameters().get('idfield');
t = [Select t.Id,t.Name__c,t.Opportunity__c,t.Phone__c,t.Account__c,t.Company__c from Talend__c t where t.Id=:eventid];
t.Name__c = talend.Name__c;
t.Company__c = talend.Company__c;
t.Phone__c = talend.Phone__c;

update t;
return new PageReference('javascript:window.close()');
}

}

-------------------------------------EDIT PAGE------------------------------------------


<apex:page standardController="Talend__c" extensions="talend1" showHeader="false" sidebar="false">
<script language="javascript">
function closeMWindow()
{
newwin = window.open(location.href,'_parent','');
newwin.close();
}
</script>

<script>
function ConfirmCancel()
{
 var isCancel = confirm("Are u sure want Cancel");
 if(isCancel) return true;
 return false;
 }
</script>

<apex:sectionHeader title="Talend Edit" subtitle="Talend"/>
<apex:form >
<apex:pageBlock title="Talend" mode="Edit">
<apex:pageBlockButtons >

<apex:commandButton value="Save" action="{!Save1}"/>
<apex:commandButton value="Cancel" action="{!Cancel}"/>
<apex:commandButton onclick="closeMWindow();" value="Close Main window"></apex:commandButton>
</apex:pageBlockButtons>
<apex:pageBlockSection title="talend" columns="1">
<apex:inputfield value="{!talend.Name__c}"/>
<apex:inputfield value="{!talend.Company__c}"/>
<apex:inputfield value="{!talend.Phone__c}"/>
<apex:inputfield value="{!talend.Account__c}"/>
<apex:inputfield value="{!talend.Opportunity__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>


No comments:

Post a Comment

Share your Comments .............