View

Wednesday, May 1, 2013

Apex Coding on Add Controller / Add Page.....

---------------------ADD CONTROLLER-----------------------------


public with sharing class aatalend {

    public aatalend(ApexPages.StandardController controller)
    {

    }
  Talend__c talend;
public Talend__c gettalend()
{
if(talend == null)
{
   talend = new Talend__c();
}
return talend;
}
public PageReference Save1()
{
Talend__c t = new Talend__c();
t.Name__c = talend.Name__c;
t.Company__c = talend.Company__c;
t.Phone__c = talend.Phone__c;
t.Account__c = talend.Account__c;
t.Opportunity__c = talend.Opportunity__c;

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

}

----------------------------------ADD PAGE-----------------------------------------


<apex:page standardController="Talend__c" extensions="aatalend" 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 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 .............