how to display success message in vf page after clicking the button
- User
how to display success message in vf page after clicking the button
- Assistant
To display a success message in a Visualforce page after clicking a button, you can follow these steps:
-
Create a Boolean variable in your controller to hold the value indicating the success status. For example,
public Boolean isSuccess { get; set; } -
In your Visualforce page, add a section to display the success message. For example
<apex:outputPanel id="successMessage" rendered="{!isSuccess}">Success!</apex:outputPanel> -
Add an
<apex:actionFunction>tag to your Visualforce page. This tag will call a method in your controller when the button is clicked.
<apex:actionFunction name="handleSuccess" action="{!handleSuccess}" rerender="successMessage"/>- In your controller, define the
handleSuccessmethod. Inside this method, set theisSuccessvariable to true to indicate the success.
public void handleSuccess() { isSuccess = true; } -