function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
bolaurent.ax1262bolaurent.ax1262 

required validation fail message is ugly

I have a bit of markup that displays a pulldown menu for an apex variable, and the field is required.

 

The markup looks like this:

 

                       <apex:pageBlockSectionItem >
                           <apex:outputLabel value="Select Territory" for="territory"/>
                           <apex:outputPanel layout="block" styleClass="requiredInput">
                               <apex:outputPanel layout="block" styleClass="requiredBlock"/>
                               <apex:actionRegion>
                               <apex:selectList value="{!theTerritoryUtility.territoryId}" 
                                                id="territory" 
                                                size="1"
                                                required="True">
                                   <apex:selectOptions value="{!theTerritoryUtility.territoryOptions}"/>
                                   <apex:actionSupport event="onchange" 
                                                       rerender="leadDelegation"/>
                               </apex:selectList>
                               </apex:actionRegion>
                           </apex:outputPanel>
                       </apex:pageBlockSectionItem>

 

 

And when the user tries to save without entering a value, the error message looks like this:

 

thePage:theForm:thePageBlock:leadDelegation:j_id368:territory: Validation Error: Value is required.

 

Is there something I can do to make the error message less ugly?

 

 

Navatar_DbSupNavatar_DbSup

Hi,

 

 

If it is possible can you please post your code (VF page + apex controller) so that we can resolve your issue in effective manner?

 

bolaurent.ax1262bolaurent.ax1262

The VF is posted above. The entire page is more complex, but I doubt that the rest of the page has anything to do with the error message that VF produces for a required field validation failure.

 

Here is the code, very simplified. I have verfiied that the VF page compiles and still produces the error.

 

public with sharing class CreateLead {
    public TerritoryUtility theTerritoryUtility {get; set;}
    
    public CreateLead(ApexPages.StandardController stdController) {
        theTerritoryUtility = new TerritoryUtility(theLead);
    }
}

 

public class TerritoryUtility {
    public Id territoryId {get; set;}
    public TerritoryUtility (Lead l) {
    }
}

 

<apex:page extensions="CreateLead" 
           standardController="Lead"
           title="Enter Lead"
           tabStyle="Lead"
           id="thePage">
                        
           <apex:form id="theForm">
               <apex:pageBlock title="Enter Lead" mode="edit" id="thePageBlock">
                   <apex:outputPanel id="messages">
                       <apex:pageMessages />
                   </apex:outputPanel>

                   <apex:pageBlockButtons id="thePageBlockButtons">
                       <apex:commandButton value="Save"
                                           action="{!save}" 
                                           id="theCreateButton"/>

                       <apex:commandButton value="Cancel" 
                                           action="{!cancel}"
                                           title="return to previous page"/>
                   </apex:pageBlockButtons>


                   <apex:pageBlockSection columns="1"  
                                          title="Lead Assignment" 
                                          id="leadDelegation">

                      <apex:pageBlockSectionItem >
                          <apex:outputLabel value="Select Territory" for="territory"/>
                              <apex:selectList value="{!theTerritoryUtility.territoryId}" 
                                               id="territory" 
                                               size="1"
                                               required="True">
                                  <apex:selectOption itemValue="" itemLabel="--None--"/>
                              </apex:selectList>
                      </apex:pageBlockSectionItem>

                   </apex:pageBlockSection>                   
               </apex:pageBlock>             
           </apex:form>
</apex:page>

 

The error on save:

 

Error:
thePage:theForm:thePageBlock:leadDelegation:j_id28:territory: Validation Error: Value is required.

 

 

 

 

 

demo42demo42

Hi Bolaurent, were you able to get a cleaner looking error message?

ShikibuShikibu

No, I was not.

demo42demo42

I figured it out, if you use the label attribute in selectlist, inputfield or inputtext the label is referenced as opposed to the component ID.

 

label="{!theTerritoryUtility.territoryId}"