Find your content:

Search form

You are here

apex:pageMessages includes the entire component tree path for a apex:inputText with required="true"

 
Share

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?


Attribution to: Daniel Ballinger

Possible Suggestion/Solution #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


Attribution to: Rao

Possible Suggestion/Solution #2

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


Attribution to: BritishBoyinDC
This content is remixed from stackoverflow or stackexchange. Please visit https://salesforce.stackexchange.com/questions/2168

My Block Status

My Block Content