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
lvivaninlvivanin 

Visualforce Error Message display format


first of all, can any body explain/show the steps on how to post a screenshot as part of the message on this community. i can see people doing this but i am unable to do so.

 

anyway i try to explain in words:

 

i am trying to display an error message

 

 

 

<apex:inputText value="{!subject}" id="Subject" maxlength="80" required="true" id="Subject_Validation"/>

<apex:message for="Subject_Validation" styleClass="locationError" />

 

 it works fine but i am getting it in Awkward format  - why j_id0:j_id2:j_id11:

 

j_id0:j_id2:j_id11:Subject_Validation: Validation Error: Value is required.

 

its same for IE/Mozilla.

 

any suggestion where i am wrong.

 

 

 

Sam.arjSam.arj

inputText does not provide a nice way showing the required messages.

 

I do not know if anyone has been able to change the default message and replace it with a more intuitive one.

 

My approach in case the form is not crowded with so many input component is to use manual validation in my controller and how a message to the user.

 

 

<apex:pageBlock title="">

<apex:pageMessages/>

<apex:inputText value="{!subject}" id="Subject" maxlength="80" id="Subject_Validation"/>

</apex:pageBlock>

 

 the in my controller I validate the data myself:

 

 

public void myAction() {

if (subject == '') {

ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Must enter a value for subject'));

return;

}

//do rest of your tasks

}

 

 

 

 

Message Edited by Sam.arj on 09-18-2009 12:45 PM
ThomasTTThomasTT

First of all, you have 2 ids in the inputText... but the 2nd one seems be chosen.

 

Second of all, j_id0:j_id2:j_id11 is ids of page, form, and proberbly pageBlock.

SFDC generate the component id based on the markups structure, so if you put id for all of markups, you will see the id like pageid:formid:pageBlockid:pageBlockSectionId:pageBlockSectionItemId:fieldId.

Id for components you didn't set id will be generated by SFDC like j_id0.

 


However, I understand that your question is, why it's not label rather than id.
At least, if it is inputField rather than inputText, the field name will be used for the message label.

I tried to use inputText with title, alt, but it didn't work.

 

I hope somebody has a good answer.

 

ThomasTT

Message Edited by ThomasTT on 09-18-2009 03:55 PM
d3developerd3developer
+1 to hoping someone comes up with a good way to handle this.
Scott.MScott.M

+ 1 Again. There shoud be an idea about this. It's a real pain to rewrite functionally just because they didn't give a way of controling the required error message in the components. All they had to do was have a "requiredMsg" attribute. *sigh*

apineda_89apineda_89

It's an old post but I was looking for an answer for the same question. I found it. If you use the apex:inputtext's attribute "label", you will recieve a friendly message. Something like 

 

<apex:inputtext value="{!yourValue}" label="Your Label" required="true" id="theInputText"/>

 

will display the next message: "Your Label: Validation Error: Value is required."

 

Hope this helps someone!

ThomasTTThomasTT

Since API 23! Finally! Thank you for the notification!!!

HDWDHDWD

Thanks a lot!!It helped us!!:)