How do I show all the errors at once on a VF page?
You must return outside your loop.
for (/*iteration*/)
{
if (/*failure condition*/)
{
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Fatal, 'message')));
}
// logic
if (/*other failure condition*/)
{
ApexPages.addMessage(/*message construction*/);
}
}
if (ApexPages.hasMessages(ApexPages.Severity.FATAL)) return null;
The problem is that you are returning from the function after you reach the first error. I can't see the whole picture from just what you've posted here, but part of the solution will be to remove the return null
statements.