You need to sign in to do that
Don't have an account?
Getting null value for the varible
<apex:page standardController="Emp__c" sidebar="false" extensions="EmpPage">
<script>
</script>
<apex:form >
<apex:pageMessages ></apex:pageMessages>
<apex:pageBlock title="Employee Edit">
<apex:pageBlockButtons > <apex:commandButton value="Save" action="{!saveRecordvalues}" immediate="true" />
<apex:commandButton value="Cancel"/>
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1" title="Information">
<apex:pageBlockSectionItem > Employee Name : <apex:inputField value="{!proxyObject.Name}"/></apex:pageBlockSectionItem>
<apex:pageBlockSectionItem > Emp No : <apex:inputField value="{!proxyObject.Emp_No__c}"/> </apex:pageBlockSectionItem>
<apex:pageBlockSectionItem > Salary : <apex:inputField value="{!proxyObject.Salary__c}"/> </apex:pageBlockSectionItem>
<apex:pageblockSectionItem >Department : <apex:inputField value="{!proxyObject.Dept__c}"/> </apex:pageblockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
-----------------------------------------
public class EmpPage {
public String retURL;
public EmpPage(ApexPages.StandardController controller) {
}
public Emp__c e {set; get; }
public Emp__c getProxyObject()
{
if ( e == null)
{
e = new Emp__c();
return e;
}
else
return e;
}
public void saveRecordvalues()
{
System.debug('***************'+e+'********'+e.Dept__c);
try
{
System.debug('*******I am in try Block*********');
if( e!= null && e.Dept__c != null)
{
Emp__c e1= new Emp__c();
e1.Name = e.Name;
e1.Salary__c = e.Salary__c;
Dept__c ls = [select Id from Dept__c where Name =: e.Dept__c limit 1];
e1.Dept__c = ls.Id;
e1.Emp_No__c = e.Emp_No__c;
insert e1;
System.debug('***********Record Inserted Successfully***************');
}
}
catch(Exception e)
{
apexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'Problem Saving Record into object' +e));
}
}
}
When ever i clicking on the button am getting null value to the "e" variable am not able to save the record. Can any one tell me wht mistake am doing in vf page.
Try adding Object e initialize [e = new Emp__c();] in constructor.
Regards
San