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
Abhilasha Singh 62Abhilasha Singh 62 

VF Page Problem

How to pass confirmation message(true or false) to the visualforce page by controller without "{get;set;}"? 
 
Ajay K DubediAjay K Dubedi
Hi Abhilasha,
For passing message from controller to vf page you can add “<apex:pageMessages />” tag anywhere where you want to add message.
And in controller  “ApexPages.addmessage” is used to send message.
Here is a Sample code which helps you.
VF Page:-
<apex:page showHeader="false" controller="CheckAvail">
<html>
 <style>
.contentStyle { font-size:12px; }
.buttonStyle { width:30%; background-color:green; text-align:center; padding-top:4px; }
</style>
 <apex:form >
 <apex:pageBlock >
 <br/><br/>
 <apex:pageBlockSection columns="2" collapsible="false">
           
               
               <apex:inputText label="Enter Your Name:" value="{!Name}"/> <br/>
          
       <apex:commandButton action="{!check}" value="Check" styleClass="buttonStyle "/>
     <apex:pageMessages />
 </apex:pageBlockSection>
</apex:pageBlock>
  
  </apex:form>
</html>

</apex:page>


controller:-
public class CheckAvail {
     Public String Name{get; set;}
    
     public PageReference check()
      {
      if(Name == 'Ajay')   //you can use condition for send message 
{
      ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Confirm,'Your Condition is True'));                
      }
      else ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'Your Condition is Wrong')); //use confirm or warning tag with your message
      
          return null;
      } 
  }


If this answers your query please mark this question as a solved so that it can be filtered out from unsolved questions.
Regards
Ajay