Posts

Showing posts from June, 2015

Ajax in Visualforce page

In Visualforce, you can use Ajax (Asynchronous JavaScript and XML) techniques to perform asynchronous requests to the server without refreshing the entire page. This allows you to update specific parts of the page dynamically, providing a smoother and more responsive user experience. Here's how you can use Ajax in Visualforce pages: Using <apex:actionFunction>: <apex:actionFunction> allows you to define a JavaScript function that invokes an Apex controller method without a full page refresh. It's typically used to perform server-side actions based on user interactions. Example <apex:page controller="MyController">     <apex:form>         <apex:commandButton value="Click Me" onclick="doAction(); return false;"/>         <apex:actionFunction name="doAction" action="{!myControllerMethod}" rerender="outputPanel"/>     </apex:form>     <apex:outputPanel id="outputPanel"...

Render a Visualforce Page as a PDF File

Image
Render a Visualforce Page as a PDF File When you render a Visualforce page as a PDF file, it can either be displayed in the browser or downloaded depending on the user's settings. The behavior may vary based on the browser, its version, and user preferences, which is beyond Visualforce's control. You can use the PDF rendering service to generate a printable PDF of a Visualforce page. Example - Visualforce Page <apex:page standardController="Contact" renderAs="pdf"> <h1>Contact Details - Hi {!Contact.Name}</h1> <p>Your account details are:</p> <table> <tr><th>Account Name</th> <td><apex:outputText value="{!Contact.Account.Name}"/></td> </tr> <tr><th>Customer Since</th> <td><apex:outputText value="{0,date,long}"> <apex:param value="{!Contact.CreatedDate}"/> </apex:outputText></t...