function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
birdofpreybirdofprey 

Only show pageMessage and nothing else.

So what I want for my visualforce page to do, depending on two cases:

  1. display the application form, with no apexPage.message.
  2. if  ApexPage.message is being call than it should only display that message and nothing else, such as the save button and tab and column headers.

Have a look at the attachment screeshot (http://i.imgur.com/gfcsJhs.jpg) and let know what you think. 

 

This is the controller that is doing all this:

        public AddLineItems(ApexPages.StandardController controller) {
            finID = ApexPages.currentPage().getParameters().get('CF00Ne0000000UEXy_lkid');
            finForm = [SELECT Id,Name,RecordTypeId,RecordType.Name, Approval_Status__c FROM Financial_Form__c WHERE Id = :finID];
            formName = finForm.Name;
            	
            String recApprovalStatus = finForm.Approval_Status__c;
            if (recApprovalStatus.contains('Processing') || recApprovalStatus.contains('Completed')){
                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, 'Approval is processing or completed, no new line items can be added.');
				ApexPages.addmessage(myMsg);
            }else{
     ...
//assign all variables to display.
            }

        } 

 

 

 

Best Answer chosen by Admin (Salesforce Developers) 
souvik9086souvik9086

Hi,

 

You can handle that by using rendered property. Keep the <apex:pageMessages> in an output panel and use the rendered property there like rendered = "{!visible = false}.

and keep everything else within another outputPanel and rendered this panel as rendered = "{!visible = true}

 

In controller

 

public Boolean visible {get;set;}

visible = true;

within constructor.

And when page message is to be displayed then made it false..like here

 

if (recApprovalStatus.contains('Processing') || recApprovalStatus.contains('Completed')){
                ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.ERROR, 'Approval is processing or completed, no new line items can be added.');
				ApexPages.addmessage(myMsg);
visible = false;

If this post solves your problem kindly mark it as solution. if this post is helpful please throw Kudos.

Thanks