When this happens to me it is usually one of two things:
(1) I don't have an component on my page
(2) I am using a rerender attribute on my or that is submitting the form and I haven't added the id of my component, which means that the error is being swallowed and the page just looks like its refreshing - I've explained this point in more detail at:
http://bobbuzzard.blogspot.co.uk/2012/08/the-importance-of-page-messages.html
However, looking at your code I don't think any pagemessages will be added - this section:
Competitor__c comp=new Competitor__c();
//List<Competitor__c> checklist=new List<Competitor__c>();
//checklist=[select Competitor_Machine__C,Competitor_Machine_Description__c from Competitor__c];
if (comp.Competitor_Machine__C == 'other' && comp.Competitor_Machine_Description__c == null)
{
ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR,'If other is selected please enter a description');//Same old drama
ApexPages.addMessage(myMsg);
// Return null so the page won't redirect
return null;
}
instantiates a new, empty Competitor__c() record, so none of the fields will be populated, which means you won't add a message. Your code then tries to insert/update the record:
try{
if(ApexPages.currentPage().getParameters().get('Name')!=null)
{
insert cc;
}
else
update cc;
}
catch(Exception e){}
return new PageReference('/'+ApexPages.currentPage().getParameters().get('retURL').substring(1,16));
}
However, if an exception occurs you can't redirect the user to a new pagereference as you are using a rerender attribute on the commandbutton, so I'd expect the page to simply refresh if an exception is thrown.
Change switch type to server:
<apex:tabPanel switchType="server" selectedTab="Survey" >
Also on "Save" button click, rerender
the tab panel. It will prevent reload or redirection of page.
Another approach (set controller variable):
<apex:tabPanel switchType="server" selectedTab="{!selectedTab}" >
Best Answer
A single field in this context where you want to pick your own label would be:
but as you are picking the standard label that will be output with just this:
So the syntax is the SObject reference name (
Lead
in this case) dot the API name of the custom field (assumingInterim_Financials_Statements__c
in this case) wrapped in the Visualforce expression delimiters{! }
.