Skip to main content Trailblazer Community 在 2025-2-1 至 2025-2-2 之间将不可访问。请相应地安排您的活动。
错误

出错了。请重试。

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 个回答
  1. 2020年2月29日 09:35
    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.
0/9000