Skip to main content 2025-2-1부터 2025-2-2까지 Trailblazer Community를 이용할 수 없습니다. 이 기간에 맞추어 활동을 계획하세요.
오류

오류가 발생했습니다. 다시 시도하세요.

Mahesh Tandan (Nuclay Solutions) 님이 #Apex에 질문했습니다
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일 오전 9: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