like if
if(data == Null || data == ''){
pexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'my error message'));
}
i'm really confused about it.
please help.3 respostas
Hi Mahesh,The simple answer is if you've marked it as required on VF page then it will be required field and you need no to handle on controller side.But just imagine a situation, where you want to reuse same controller on the other VF page. If you don't want that field to be as required on that VF page don't use this attribute.So, it depends on you're requirement.Thanks,Ashish Singh. Hi Mahesh,No you can handle it in VF page.For better understanding please execute below code in your org and you can see validation error.=======================================================<apex:page standardController="Contact"><apex:form><apex:messages/><apex:pageBlock title="PageBlock" mode="edit"><apex:pageBlockSection title="Page block section"> <apex:outputLabel value="Birth date" for="mId"/> <apex:outputPanel styleClass="requiredInput" layout="block"> <apex:outputPanel styleClass="requiredBlock" layout="block"/> <apex:inputText value="{!contact.Birthdate}" required="true" id="mId"/> </apex:outputPanel></apex:pageBlockSection><apex:pageblockButtons><apex:commandButton action="{!save}" value="save"></apex:commandButton></apex:pageblockButtons></apex:pageBlock></apex:form></apex:page>==========================================================Hope this helps you.Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future.Thanks,Vinay Kumar