• DhirajJain.ax414
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Hi All,
 
I am using VisualForce pages in my application with Standardcontroller as a Custom Sobject FTP_Details  .
This page has three Input fields which are manadatory,fields name like Organization,Language,Email account.
For the input field Organization, i need to display a custom message.
Hence I have added custom message in relative controller and also added tag <apex:message styleClass="error"/> in VisualForce Page.
But the custom message is not being displayed on Page.
 
Controller code:
 
public PageReference saveAndNext(){
String id;
System.debug('Organizatio is =='+details.Organization__c);
System.debug('Language is =='+details.Language__c);
System.debug('Email is =='+details.Email__c);
if(('').equals(details.Organization__c) || ('').equals(details.Email__c) || details.Language__c==null){
return null;}

try{

Integer countOrg=[Select count() from FTP_Details__c ft where ft.Organization__c=:details.Organization__c];

if(countOrg>0){

throw new ValidationException('Organization '+details.Organization__c+' exists in DataBase');

}

FTP_Details__c ftpSave=new FTP_Details__c();

ftpSave.Language__c=details.Language__c;

ftpSave.Organization__c=details.Organization__c;

ftpSave.Email__c=details.Email__c;

insert ftpSave;

id=ftpSave.Id;

}catch(ValidationException e){

ApexPages.Message myMsg = new ApexPages.Message(ApexPages.severity.ERROR,

'Error retrieving competitive wins: ' + e.getMessage());

ApexPages.addMessage(myMsg);

System.debug('Error is======'+e.getMessage());

return null;

}

String newPageUrl = '/apex/SetUpTab?userId='+id;

PageReference newPage = new PageReference(newPageUrl);

newPage.setRedirect(true);

return newPage;

}

 

VisualForce page code:

<apex:form >
      <apex:pageBlock >
       <apex:pageblockButtons >
        <apex:commandButton action="{!saveAndNext}" value="Save & Next" />
        <apex:commandButton action="{!cancel}" value="Cancel"/>
    </apex:pageblockButtons>
    <font color="red"><apex:message styleClass="error"/> </font>
                 <table>
          <tr>

Thanks in advance.