8

I have a Visualforce page that contains an apex:inputText with required="true". It is nested within several component levels, such as a apex:pageBlockSectionItem, apex:pageBlockSection, apex:pageBlock and apex:form.

If I submit the form without entering a value I get the following output in the apex:pageMessages:

apex:pageMessages with entire component tree path for required inputText

Error: mediaPage:mediaPageBlock:mediaForm:dropBlock:requiredElementsSection:goalsSectionItem:goals: Validation Error: Value is required.

The component tree path is meaningless to the users.

Is there anyway to reformat this message or do I need to drop the required attribute on the inputText and validate the input myself in the controller?

11

Try adding a label attribute to the inputText field - if there is no label, the error will display the whole tree, but with a label, it should just display the label + error message

  • 2
    I was about to say that this doesn't work when I noticed in the docs that inputText.label is API v23.0. Once I updated it worked perfectly. Thanks. – Daniel Ballinger Oct 10 '12 at 21:45
-1

Just an assumption are u using try catch in the VF page and trying to throw exception ? If so are you using

try {               
       }
  catch (Exception e) {       

ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'Error: Invalid Input.'); ApexPages.addMessage(myMsg);

        }       

use ApexPages.addMessages(e); instead of

  • 1
    I'm reasonably certain the error message isn't coming from my controller code. Rather, the validation that is built into Visualforce is raising it. – Daniel Ballinger Oct 10 '12 at 21:09
  • ah i wasn't sure if it was coming from the controller that's the reason i had as assumption ") – Rao Oct 10 '12 at 21:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.