public class MyController{
List<sObject> myRecords {get; private set;}
public MyController(ApexPages.StandardController ctrl){
queryRecords();
}
public PageReference queryRecords(){
myRecords = [Select Id From MyObject];
if(myRecords.isEmpty()){
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'List is empty'));
}
return;
}
}
emm.. I don't understand what you're trying to do. But you can add just, for example <h3 style="color:red"><b>{!errors}</b></h3> to your component and set error message into "error" variable in your component's controller.
public class MyController{
List<sObject> myRecords {get; private set;}
public MyController(ApexPages.StandardController ctrl){
queryRecords();
}
public PageReference queryRecords(){
myRecords = [Select Id From MyObject];
if(myRecords.isEmpty()){
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO, 'List is empty'));
}
return;
}
}
Just add is isErrorVisible : Booleand errorMessage : String to your controller. You can use ApexPages.getMessages() method to retieve messages in contoller.
<apex:component controller="findMapKey" access="global">
<div id="introArea" class="grayBg" style="width: 100%;height: 520px;text-align: center;padding-top: 200px;background-image: url('/resource/1404321030000/CMapsDesigner/img/splash.png');background-repeat: no-repeat;background-position-y:0px;background-size: cover;">
<input type="file" id="fiOpenMap" style="display:none"/>
<apex:attribute name="myValue" description="This is the value for the component." type="String" />
<apex:pageMessages />
<apex:dataTable value="{!MapKey}" var="mkey">
<apex:column >
<button style="width: 200px;height: 50px;"
onClick="location.href='/resource/1404321030000/CMapsDesigner/designer.html?usessl=true&authkey={!mkey.mapKey__c}'"
type="button" class="btn btn-default">
Create a Geographic Map
</button>
</apex:column>
</apex:dataTable>
<button style="width: 200px;height: 50px;"
onClick="alert('Coming Soon')"
type="button" class="btn btn-default">
Create an Indoor Map
</button>
<apex:outputPanel id="marketinginfo" redered={hasErrors}>
Need help? Contact us at support@centigonsolutions.com
</apex:outputPanel>
</div>
</apex:component>
And controller
public class findMapKey {
private final List<GMapsPluginEnterpriseTrial__c> obj_mapkey;
public Integer count {get;set;}
public findMapKey() {
obj_mapkey= [select mapKey__c from GMapsPluginEnterpriseTrial__c where expirationDate__c < TODAY and isActive__c = true and Type__c='Designer' limit 1 ];
count = [select count() from GMapsPluginEnterpriseTrial__c where expirationDate__c < TODAY and isActive__c = true and Type__c='Designer' limit 1 ];
}
public Boolen hasErrors{get;set;}
public List<GMapsPluginEnterpriseTrial__c> getMapKey() {
if(obj_mapkey.isEmpty()){
hasErrors=true;
}
return obj_mapkey;
}
}
In your controller, you can use ApexPages.addMessage() to add a message if your list is empty, and then use apex:pageMessages to display it on your Visualforce page. https://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_pageMessages.htm
Your controller might look something like:
And your VF page may look like:
All Answers
Hope it helps.
If you have problems let me know.
In your controller, you can use ApexPages.addMessage() to add a message if your list is empty, and then use apex:pageMessages to display it on your Visualforce page. https://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_pageMessages.htm
Your controller might look something like:
And your VF page may look like:
Just add is
isErrorVisible : Booleand
errorMessage : String
to your controller.
You can use ApexPages.getMessages() method to retieve messages in contoller.
Try this and tell me if this helps or not