You need to sign in to do that
Don't have an account?
Esther Thomas 2
assigning datetime custom field value is throwing an exception :(
Hi Everyone,
I'm trying a simple test
1. passing in a custom field (datetime) from my VF page to my apex controller.
2. take the datetime value passed and reassing it to a new datetime variable
3. convert datetime value in variable to string and have it re-rendered in my pagblocksection
When the action method is called, assigning that custom field datetime value seems to be throwing an exception. Pulling my hair out. Not sure where I've messed this up or misunderstood how this is suppose to work. Thanks in advance!
I'm trying a simple test
1. passing in a custom field (datetime) from my VF page to my apex controller.
2. take the datetime value passed and reassing it to a new datetime variable
3. convert datetime value in variable to string and have it re-rendered in my pagblocksection
When the action method is called, assigning that custom field datetime value seems to be throwing an exception. Pulling my hair out. Not sure where I've messed this up or misunderstood how this is suppose to work. Thanks in advance!
<apex:page standardController="Booking__c" extensions="testing7"> <apex:form> <apex:pageBlock> <apex:pageBlockSection> <apex:inputfield value="{!Records.Start_Date_Time__c}"> <apex:actionSupport action="{!UpdateSitter}" event="onchange" reRender="D1"/> </apex:inputfield> </apex:pageBlockSection> <apex:pageBlockSection columns="1" id="D1"> <apex:pageBlockTable value="{!Sdate}" var="sd" rendered="{!FlagH}"> <apex:column value="{!sd}"/> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page> public class testing7 { public Booking__c Records{get;set;} public String Sdate{get;set;} public Datetime DT{get;set;} public Boolean FlagH{get;set;} public PageReference UpdateSitter(){ FlagH=true; try{ DT = Records.Start_Date_Time__c; //throwing an exception on this line Sdate=String.ValueOf(DT); }catch(System.NullPointerException e){ Sdate='fail'; } return null; } public testing7(ApexPages.StandardController controller) {} }
to
For more information - https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/apex_pages_standardcontroller.htm
Hope this helps