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.
If you have a list of list "List < List < String>>" you will need to do something like :
<apex:repeat value="{!alist}" var="l">
<apex:dataList value="{!l}" var="c">
{!c}
</apex:dataList>
</apex:repeat>
Best Answer
Please make sure that you have a boolean attribute defined in your controller named
readValue
.Controller:
Also in your page set the value of the input checkbox as follows:
Page: