Skip to main content Construya el futuro con Agentforce en TDX, San Francisco o en Salesforce+ del 5 al 6 de marzo. Regístrese ahora.
I have a visualforce page and a custom controller

vf page have a form and required fields and i'm validating it throught <apex:inputtext value="{!data}" required="true">

my question is do I need to validate it in my controller also?

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 respuestas
  1. 29 feb 2020, 9:35 a.m.
    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.
Cargando
0/9000